API that returns a newly allocated buffer as an output argument (not return value) are error-prone.
- Users forget to release the newly allocated buffer
- Or the call `delete` instead of `delete[]`
But some of those API need to call `realloc` on the buffer.
But `realloc` is only valid if the buffer was previously allocated with `malloc`.
If a buffer needs to be re-allocated using a C++ API, then `std::vector<char*>` should be used instead...
So, this patch does:
- Migrates the API from `new []` / `delete[]` to `malloc()` / `free()`
- Fixes all the memory issues: incorrect deallocs and memory leaks
- Updates the documentation
- And fixes misc issues with the API: removes `cc` from the ZipUtils class.
... instead of const char*
* Because it is more robust
* and it is faster... yes faster.
It is faster because internally some of our classes use std::string
(like FileUtils and Dictionary) so converting back-and-forth from const
char * to std::string is very expensive.
It is faster to have everthing in std::string as soon as possible to
prevent further conversions.
There are still some parts of the code that require conversion, but
most of the code was converted.