When we build with AddressSanitizer (ASan) in GCC, we can see a lot of memory
leaks and a buffer overflow issue in unit tests and arg_file implementation.
The root cause of memory leaks in unit tests is that, we never care about
releasing memory in unit test code. Besides, the semantics of CuSuiteAddSuite()
makes releasing a test suite very difficult. By fixing CuSuiteAddSuite() and
carefully releasing memory in unit tests, memory leaks are resolved.
The root cause of the buffer overflow issue in arg_file is that, we mix pointer
and array operations together. By using strlen(result) instead of result[1] to
determine the string length, the buffer overflow issue is resolved.
resolves: #46
This is a huge commit since the last one. Here are the major changes:
- Add original source files and the amalgamation generator utilities
- Add dynamic string utilities (arg_dstr) used to generator output
- Add hash table utilities (arg_hashtable) used to store sub-commands
- Add utilities (arg_cmd) used to implement the sub-command mechanism
- Use clang-format to unify the coding style
- Add new unit tests
- Fix warnings under strict compiler settings in VC and GCC
- Add ARG_REPLACE_GETOPT to choose the built-in or system getopt
- Add utilities to generate help messages
- Cleanup the mess after various pull requests