My first C++ conversion target is wfdbio.c with wfdb.h and wfdblib.h. Trying to compile this with C++ settings results in several errors from the memory allocation macros, such as: a value of type "void *" cannot be assigned to an entity of type "char *" when calling SALLOC.
We should try to replace them with standard C++ API calls where possible. This may also include replacing char* with std::string where required. I haven't looked into all of the macros, why they are/were needed, or potential solutions, so feel free to discuss all of that in this issue.
Strategy to break down this work:
Identify and document the replacement strategy for each macro
Remove macros and replace usage in lib directory
Replace usage in other directories
Checklist:
[ ] SFREE:: Safely release allocated memory.
[ ] SUALLOC:: Safely allocate memory using a new pointer.
[ ] SALLOC:: Safely allocate memory, reusing a pointer.
[ ] SREALLOC:: Safely expand a chunk of allocated memory.
[ ] SSTRCPY:: Safely copy a string into a new buffer.
An alternative working order is to keep the macros for now, and add the required C++ typecasts in order to compile the library. And then to remove the macros one at a time.
My first C++ conversion target is
wfdbio.c
withwfdb.h
andwfdblib.h
. Trying to compile this with C++ settings results in several errors from the memory allocation macros, such as:a value of type "void *" cannot be assigned to an entity of type "char *"
when callingSALLOC
.List of said macros: https://github.com/bemoody/wfdb/blob/master/doc/wpg-src/wpg0.tex#L4693
We should try to replace them with standard C++ API calls where possible. This may also include replacing
char*
withstd::string
where required. I haven't looked into all of the macros, why they are/were needed, or potential solutions, so feel free to discuss all of that in this issue.Strategy to break down this work:
lib
directoryChecklist: