Fixed C++ compiler complaints

From carothersc/ROSS@e9d23795baf6f5f7e39b943258d94ff5fb0eb6d6
- added type casts for malloc calls
- typedef enums after definition
- TWOPT_END() fix