Skip to content

Commit edca7a1

Browse files
committed
Deletion of empty map bug fix
1 parent 4ff7eb1 commit edca7a1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

linked_hash_map.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ struct LinkedHashMap *createHashMap() {
1818

1919
void deleteMap(struct LinkedHashMap *map) {
2020
struct Entry *elem = map->head;
21+
if (elem == NULL) {
22+
free(map);
23+
return;
24+
}
2125
struct Entry *next = map->head->after;
2226
while (next != NULL) {
2327
free(elem);

0 commit comments

Comments
 (0)