Overhaul hashmap_t
functionalities
#191
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This patch fixes constracts of
hashmap_t
-related function, including:hashmap_contains
: Instead of delegates to result returned byhashmap_get
, now shares similar logic to avoid bucket node value beingNULL
and treat as false.hashmap_free
: Now respects bucket node value's pointer, if it's alreadyNULL
, then hashmap won't free it.Additionally, now
hashmap_t
is capable of rehashing its underlying bucket node array when load factor reaches 75%.Closes #190.
Summary by Bito
This pull request enhances the `hashmap_t` functionalities by implementing a rehashing mechanism triggered at a 75% load factor, refining the `hashmap_contains` logic to avoid incorrect NULL returns, and updating `hashmap_free` for better memory management. These improvements optimize the performance and reliability of the hashmap, ensuring a more robust implementation.Unit tests added: False
Estimated effort to review (1-5, lower is better): 2