Skip to content

Commit 4a4656d

Browse files
committed
Merge branch 'en/hashmap-clear-fix'
hashmap API clean-up to ensure hashmap_clear() leaves a cleared map in a reusable state. * en/hashmap-clear-fix: hashmap: ensure hashmaps are reusable after hashmap_clear()
2 parents 6f84262 + 9481877 commit 4a4656d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

hashmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,9 @@ void hashmap_clear_(struct hashmap *map, ssize_t entry_offset)
205205
return;
206206
if (entry_offset >= 0) /* called by hashmap_clear_and_free */
207207
free_individual_entries(map, entry_offset);
208-
free(map->table);
209-
memset(map, 0, sizeof(*map));
208+
FREE_AND_NULL(map->table);
209+
map->tablesize = 0;
210+
map->private_size = 0;
210211
}
211212

212213
struct hashmap_entry *hashmap_get(const struct hashmap *map,

0 commit comments

Comments
 (0)