diff --git a/src/UDPC_HashMap.c b/src/UDPC_HashMap.c index ef09703..90d14fc 100644 --- a/src/UDPC_HashMap.c +++ b/src/UDPC_HashMap.c @@ -90,6 +90,8 @@ void* UDPC_HashMap_insert(UDPC_HashMap *hm, uint32_t key, void *data) } } + UDPC_HashMap_remove(hm, key); + uint32_t hash = UDPC_HASH32(key) % hm->capacity; char *temp = malloc(sizeof(uint32_t) + hm->unitSize); diff --git a/src/UDPC_HashMap.h b/src/UDPC_HashMap.h index 3aadd9c..c91caeb 100644 --- a/src/UDPC_HashMap.h +++ b/src/UDPC_HashMap.h @@ -46,6 +46,8 @@ void UDPC_HashMap_destroy(UDPC_HashMap *hashMap); * Note if size already equals capacity, the hash map's capacity is doubled * with UDPC_HashMap_realloc(). realloc requires rehashing of all items which * may be costly. + * If an item with the same key already exists in the hash map, it will be + * replaced. * \return Internally managed pointer to inserted data, NULL on fail */ void* UDPC_HashMap_insert(UDPC_HashMap *hm, uint32_t key, void *data);