From a95b064d6d0a2e3dfa8c414be60ae966a099adfd Mon Sep 17 00:00:00 2001 From: gingerBill Date: Fri, 21 Apr 2023 13:29:38 +0100 Subject: Fix memory leak caused by awful realloc usage on Linux --- src/string_map.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/string_map.cpp') diff --git a/src/string_map.cpp b/src/string_map.cpp index bf1bbf6ca..f8b86a950 100644 --- a/src/string_map.cpp +++ b/src/string_map.cpp @@ -96,7 +96,9 @@ gb_internal MapIndex string_map__add_entry(StringMap *h, u32 hash, String con e.key = key; e.hash = hash; e.next = MAP_SENTINEL; - string_map__reserve_entries(h, h->count+1); + if (h->count+1 >= h->entries_capacity) { + string_map__reserve_entries(h, gb_max(h->entries_capacity*2, 4)); + } h->entries[h->count++] = e; return cast(MapIndex)(h->count-1); } -- cgit v1.2.3