Fixed leaks in hashmap
This commit is contained in:
parent
544ed8b045
commit
f75685a6c7
12 changed files with 99 additions and 75 deletions
|
|
@ -73,7 +73,7 @@ typedef struct s_hashmap_C__PREFIX__
|
|||
/// @param cmp The comparison function
|
||||
/// @param drop The drop function
|
||||
/// @return A new hashmap
|
||||
t_hashmap_C__PREFIX__ *hmap_new_C__PREFIX__(t_hash_C__PREFIX___fn hash, t_eq_C__PREFIX___fn cmp, t_drop_C__PREFIX___fn drop);
|
||||
t_hashmap_C__PREFIX__ *hmap_C__PREFIX___new(t_hash_C__PREFIX___fn hash, t_eq_C__PREFIX___fn cmp, t_drop_C__PREFIX___fn drop);
|
||||
|
||||
/// @brief Creates a new hashmap with the given hash, comparison, and drop functions
|
||||
/// @param hash The hash function
|
||||
|
|
@ -81,27 +81,29 @@ t_hashmap_C__PREFIX__ *hmap_new_C__PREFIX__(t_hash_C__PREFIX___fn hash, t_eq_C__
|
|||
/// @param drop The drop function
|
||||
/// @param cap The number of buckets
|
||||
/// @return A new hashmap
|
||||
t_hashmap_C__PREFIX__ *hmap_new_with_buckets_C__PREFIX__(t_hash_C__PREFIX___fn hash, t_eq_C__PREFIX___fn cmp, t_drop_C__PREFIX___fn drop, size_t cap);
|
||||
t_hashmap_C__PREFIX__ *hmap_C__PREFIX___new_with_buckets(t_hash_C__PREFIX___fn hash, t_eq_C__PREFIX___fn cmp, t_drop_C__PREFIX___fn drop, size_t cap);
|
||||
|
||||
/// @brief Drops the hashmap and all of its entries
|
||||
/// @param hmap The hashmap to drop
|
||||
void hmap_free_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap);
|
||||
/// @brief Free the hashmap and all of its entries
|
||||
/// @param hmap The hashmap to free
|
||||
void hmap_C__PREFIX___free(t_hashmap_C__PREFIX__ *hmap);
|
||||
|
||||
/// @brief Inserts a key-value pair into the hashmap
|
||||
/// @param hmap The hashmap
|
||||
/// @param key The key
|
||||
/// @param value The value
|
||||
void hmap_insert_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ key, C__VALTYPE__ value);
|
||||
/// @return true if the key already existed before, false otherwise
|
||||
bool hmap_C__PREFIX___insert(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ key, C__VALTYPE__ value);
|
||||
|
||||
/// @brief Gets the value associated with the key
|
||||
/// @param hmap The hashmap
|
||||
/// @param key The key
|
||||
/// @return The value associated with the key, or NULL if the key is not in the hashmap
|
||||
C__VALTYPE__ *hmap_get_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
|
||||
C__VALTYPE__ *hmap_C__PREFIX___get(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
|
||||
|
||||
/// @brief Removes the key-value pair from the hashmap
|
||||
/// @param hmap The hashmap
|
||||
/// @param key The key
|
||||
void hmap_remove_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
|
||||
void hmap_C__PREFIX___remove(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
|
||||
|
||||
/// @brief Get an entry from the hashmap
|
||||
/// @param hmap The hashmap
|
||||
|
|
@ -110,7 +112,7 @@ void hmap_remove_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, C__KEYTYPE__ *key);
|
|||
/// @param prev The previous entry in the bucket
|
||||
/// @return The entry, or NULL if the key is not in the hashmap
|
||||
/// @note this is an internal function
|
||||
t_entry_C__PREFIX__ *hmap_get_entry_C__PREFIX__(t_hashmap_C__PREFIX__ *hmap, t_usize hash, C__KEYTYPE__ *key, t_entry_C__PREFIX__ **prev);
|
||||
t_entry_C__PREFIX__ *hmap_C__PREFIX___get_entry(t_hashmap_C__PREFIX__ *hmap, t_usize hash, C__KEYTYPE__ *key, t_entry_C__PREFIX__ **prev);
|
||||
|
||||
/// @brief Iterates over the hashmap and calls the given function for each key-value pair
|
||||
/// @param self The hashmap
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue