These are some issues that I already resolved in the c-string lib. I'd like to contribute the solutions to the c-vector lib, too. Tracking them in only one report should be good enough.
Warnings
One of the disadvantages of a macro lib is that macros are expanded into the user code and, thus, suppressing certain warnings in the header file is not effective. We cannot control what warnings the users enabled. In the consequence they might find themself lost in too many warnings caused by our lib, not being able to find the warnings caused by their code anymore. Since we certainly don't want to force users to disble warnings that might be useful from their point of view, we should do our best to avoid making too many noises.
Potential memory leaks
These are some issues that I already resolved in the
c-stringlib. I'd like to contribute the solutions to thec-vectorlib, too. Tracking them in only one report should be good enough.Warnings
One of the disadvantages of a macro lib is that macros are expanded into the user code and, thus, suppressing certain warnings in the header file is not effective. We cannot control what warnings the users enabled. In the consequence they might find themself lost in too many warnings caused by our lib, not being able to find the warnings caused by their code anymore. Since we certainly don't want to force users to disble warnings that might be useful from their point of view, we should do our best to avoid making too many noises.
cv_sz__being shadowed incvector_growwhenevercvector_resizeis called. There is a certain risk that also other variables are shadowed if users nest macro calls.cvector_vec_to_baseperforms a type cast from a pointer to element type to a pointer tocvector_metadata_t. Depending on the size of the element type, compilers may throw a warning that casting would change the data alignment.void *to emphasize our intention and appease the compiler. PR avoid cast-align warnings #86Potential memory leaks