fix: fix memory leak in map_put
thanks dylan :)
This commit is contained in:
6
map.c
6
map.c
@@ -95,10 +95,12 @@ static __inline uint32_t map_index(Map *map, int key) {
|
||||
__inline void map_set_node(Map *map, MapNode node) {
|
||||
MapNode *current = &map->nodes[map_index(map, node.key)];
|
||||
if(current->next == NULL || current->key == node.key) {
|
||||
if(current->next == NULL) map->size++;
|
||||
current->key = node.key;
|
||||
current->value = node.value;
|
||||
current->next = (MapNode*) UINTPTR_MAX;
|
||||
if(current->next == NULL) {
|
||||
map->size++;
|
||||
current->next = (MapNode*) UINTPTR_MAX;
|
||||
}
|
||||
} else {
|
||||
while((size_t) current->next != UINTPTR_MAX) {
|
||||
current = current->next;
|
||||
|
||||
Reference in New Issue
Block a user