Skip to content

Integrate certain fixes for issues found in c-string into c-vector. #88

@german-one

Description

@german-one

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 in cvector_grow whenever cvector_resize is 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
  • -Wcast-align
    • cvector_vec_to_base performs a type cast from a pointer to element type to a pointer to cvector_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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions