Clean up the orbit_info.bin generation program
Closed this issue · 0 comments
LandonTClipp commented
We need to clean up the program that generates the orbit_info.bin file.
TODO:
- Remove debugging output (printf statements)
- Comment the code using C style comments... /* comment */
- Add proper error handling. Make use of the "FATAL_MSG" and "WARN_MSG" function-like macros (refer to libTERRA.h to see where these are defined. Copy-paste these definitions into the generation program and use them for error messages). Refer to the entire basic fusion program to see how error handling is done and then utilize the same format. More specifically:
- Declare ALL variables, pointers or otherwise, that will eventually contain malloc'ed memory or any identifier that will eventually need to be freed or closed, at the TOP of the function. Initialize all these variables to zero or NULL.
- Once any variable has been freed or closed, immediately set the variable to 0 (or NULL for pointers)
- At the end of the function, perform if-statement checks on every variable that has ever contained malloc'ed memory (or ever contained an identifier to an object that needs to be closed) to see if it is non-zero. If the variable is non-zero, that means that it must be freed or closed before the function returns. This is done to prevent memory leaking!
- If at any point a function call fails, print an error message using FATAL_MSG or WARN_MSG and use a goto statement to make program execution go to just before all of the free/close checks. Make sure that in this case, the function will return a non-zero return code.
- Remove the hard-coded file paths. Replace these with arguments to the program.
- Use valgrind to check for memory leaks once all this is done
DO NOT upload the file to GitHub. Keep it at your local machine.