diff --git a/src/common_memory.cpp b/src/common_memory.cpp index 22b91d8cb..e07276aa1 100644 --- a/src/common_memory.cpp +++ b/src/common_memory.cpp @@ -509,7 +509,7 @@ gb_internal GB_ALLOCATOR_PROC(heap_allocator_proc) { template -gb_internal isize resize_array_raw(T **array, gbAllocator const &a, isize old_count, isize new_count) { +gb_internal isize resize_array_raw(T **array, gbAllocator const &a, isize old_count, isize new_count, isize custom_alignment=1) { GB_ASSERT(new_count >= 0); if (new_count == 0) { gb_free(a, *array); @@ -521,7 +521,7 @@ gb_internal isize resize_array_raw(T **array, gbAllocator const &a, isize old_co } isize old_size = old_count * gb_size_of(T); isize new_size = new_count * gb_size_of(T); - isize alignment = gb_align_of(T); + isize alignment = gb_max(gb_align_of(T), custom_alignment); auto new_data = cast(T *)gb_resize_align(a, *array, old_size, new_size, alignment); GB_ASSERT(new_data != nullptr); *array = new_data; diff --git a/src/parser.cpp b/src/parser.cpp index 0eb7e5fc1..c26ca3dcb 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -89,7 +89,7 @@ gb_internal Array clone_ast_array(Array const &array, AstFile *f) gb_internal Slice clone_ast_array(Slice const &array, AstFile *f) { Slice result = {}; if (array.count > 0) { - result = slice_clone(permanent_allocator(), array); + result = slice_clone(ast_allocator(nullptr), array); for_array(i, array) { result[i] = clone_ast(array[i], f); } diff --git a/src/string_map.cpp b/src/string_map.cpp index 3bd08d09f..067adef28 100644 --- a/src/string_map.cpp +++ b/src/string_map.cpp @@ -1,5 +1,11 @@ GB_STATIC_ASSERT(sizeof(MapIndex) == sizeof(u32)); +enum { + STRING_MAP_CACHE_LINE_SIZE_POW = 6, + STRING_MAP_CACHE_LINE_SIZE = 1< *h) { template gb_internal void string_map__resize_hashes(StringMap *h, usize count) { - h->hashes_count = cast(u32)resize_array_raw(&h->hashes, string_map_allocator(), h->hashes_count, count); + h->hashes_count = cast(u32)resize_array_raw(&h->hashes, string_map_allocator(), h->hashes_count, count, STRING_MAP_CACHE_LINE_SIZE); } template gb_internal void string_map__reserve_entries(StringMap *h, usize capacity) { - h->entries_capacity = cast(u32)resize_array_raw(&h->entries, string_map_allocator(), h->entries_capacity, capacity); + h->entries_capacity = cast(u32)resize_array_raw(&h->entries, string_map_allocator(), h->entries_capacity, capacity, STRING_MAP_CACHE_LINE_SIZE); }