Skip to content

Commit

Permalink
Map API fix: avoid destroying map value upon update with same value p…
Browse files Browse the repository at this point in the history
…ointer.
  • Loading branch information
FedeDP committed Aug 22, 2019
1 parent a7a0dd5 commit 28ce240
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static map_ret_code hashmap_put(map_t *m, const char *key, void *value) {
if (!entry->key) {
entry->key = key;
m->length++;
} else if (m->dtor) {
} else if (m->dtor && entry->data != value) {
/* Destroy old value if needed */
m->dtor(entry->data);
}
Expand Down
1 change: 1 addition & 0 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ conversely to module_stop that should stop module right away freeing all its enq
- [x] Set keydup and autofree in map_new()
- [x] Drop map_set_dtor
- [x] Destroy old value upon val update
- [x] Avoid destroying map value on update with same pointer; just return MAP_OK

### Stack
- [x] stack->dtor should default to memhook._free, and fallback to default if stack_set_dtor is called with NULL callback parameter
Expand Down

0 comments on commit 28ce240

Please sign in to comment.