v1.1.1 - Added new hm_of() helper macro
This commit is contained in:
9
hm.h
9
hm.h
@@ -1,4 +1,4 @@
|
|||||||
// hm.h - v1.1.0 - MIT License
|
// hm.h - v1.1.1 - MIT License
|
||||||
// chained hash table implementation as a single header library.
|
// chained hash table implementation as a single header library.
|
||||||
//
|
//
|
||||||
// [License and changelog]
|
// [License and changelog]
|
||||||
@@ -82,6 +82,11 @@
|
|||||||
// This function returns the value associated with the specified key. Returns
|
// This function returns the value associated with the specified key. Returns
|
||||||
// NULL if key was not found.
|
// NULL if key was not found.
|
||||||
//
|
//
|
||||||
|
// type *hm_of(type, hm, key)
|
||||||
|
//
|
||||||
|
// Helper macro wrapper for hm_get with an additional type parameter so the
|
||||||
|
// result is already casted to the desired type.
|
||||||
|
//
|
||||||
// bool hm_remove(HashMap *hm, const void *key)
|
// bool hm_remove(HashMap *hm, const void *key)
|
||||||
//
|
//
|
||||||
// This function removes the entry associated with the specified key. Returns
|
// This function removes the entry associated with the specified key. Returns
|
||||||
@@ -190,6 +195,7 @@ void hm_free(HashMap *hm);
|
|||||||
// Modify, access and remove
|
// Modify, access and remove
|
||||||
bool hm_put(HashMap *hm, const void *key, const void *value);
|
bool hm_put(HashMap *hm, const void *key, const void *value);
|
||||||
void *hm_get(const HashMap *hm, const void *key);
|
void *hm_get(const HashMap *hm, const void *key);
|
||||||
|
#define hm_of(type, hm, key) (type*)hm_get((hm), (key))
|
||||||
bool hm_remove(HashMap *hm, const void *key);
|
bool hm_remove(HashMap *hm, const void *key);
|
||||||
size_t hm_count(const HashMap *hm);
|
size_t hm_count(const HashMap *hm);
|
||||||
|
|
||||||
@@ -666,6 +672,7 @@ Hm__Bucket *hm__bucket_create(const void *key, size_t key_size, const void *valu
|
|||||||
/*
|
/*
|
||||||
* Revision history:
|
* Revision history:
|
||||||
*
|
*
|
||||||
|
* 1.1.1 (2026-02-13) Added new hm_of() helper macro
|
||||||
* 1.1.0 (2026-01-10) Added new hm_count() function;
|
* 1.1.0 (2026-01-10) Added new hm_count() function;
|
||||||
* Fix value_size comparison in hm_put();
|
* Fix value_size comparison in hm_put();
|
||||||
* Fix memory leak on failed reallocation in hm_put();
|
* Fix memory leak on failed reallocation in hm_put();
|
||||||
|
|||||||
Reference in New Issue
Block a user