diff --git a/hm.h b/hm.h index 2114615..2d59a67 100644 --- a/hm.h +++ b/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. // // [License and changelog] @@ -82,6 +82,11 @@ // This function returns the value associated with the specified key. Returns // 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) // // This function removes the entry associated with the specified key. Returns @@ -190,6 +195,7 @@ void hm_free(HashMap *hm); // Modify, access and remove bool hm_put(HashMap *hm, const void *key, const void *value); 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); 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: * + * 1.1.1 (2026-02-13) Added new hm_of() helper macro * 1.1.0 (2026-01-10) Added new hm_count() function; * Fix value_size comparison in hm_put(); * Fix memory leak on failed reallocation in hm_put();