src/hash_map.c

changeset 1114
ad5eeb256242
parent 1111
78eeeb950883
child 1115
6db21dee4929
--- a/src/hash_map.c	Tue Jan 07 18:37:07 2025 +0100
+++ b/src/hash_map.c	Tue Jan 07 19:16:03 2025 +0100
@@ -103,7 +103,8 @@
 
     if (elm != NULL && elm->key.hash == hash && elm->key.len == key.len &&
         memcmp(elm->key.data, key.data, key.len) == 0) {
-        // overwrite existing element
+        // overwrite existing element, but call destructors first
+        cx_invoke_destructor(map, elm->data);
         if (map->collection.store_pointer) {
             memcpy(elm->data, &value, sizeof(void *));
         } else {

mercurial