-
Notifications
You must be signed in to change notification settings - Fork 112
Closed
Description
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.
- -Wshadow
- Currently, variables declared in the macros have duplicate names within the lib. This causes
cv_sz__being shadowed incvector_growwhenevercvector_resizeis called. There is a certain risk that also other variables are shadowed if users nest macro calls. - Possible solution: Having unique names for all variables declared across all macros of the lib both solves the issue faced and protects us from potential issues of that kind. PR avoid variable shadowing #83
- Currently, variables declared in the macros have duplicate names within the lib. This causes
- -Wcast-align
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.- Possible solution: Insert a preliminary cast to
void *to emphasize our intention and appease the compiler. PR avoid cast-align warnings #86
Potential memory leaks
- Overridden functions
- Allocation, reallocation, and deallocation functions need to be harmonized whenever they get overridden. They must not belong to different libraries.
- Possible solution: At least ensure that either all or none of the used memory management functions are overridden. PR ensure harmonized memory management functions #87
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels