From edb210905dcbe666fa5222bceacd2e5bdb16bb89 Mon Sep 17 00:00:00 2001 From: Michael Dusan Date: Mon, 10 Feb 2020 21:08:08 -0500 Subject: stage1: memory/report overhaul - split util_base.hpp from util.hpp - new namespaces: `mem` and `heap` - new `mem::Allocator` interface - new `heap::CAllocator` impl with global `heap::c_allocator` - new `heap::ArenaAllocator` impl - new `mem::TypeInfo` extracts names without RTTI - name extraction is enabled w/ ZIG_ENABLE_MEM_PROFILE=1 - new `mem::List` takes explicit `Allocator&` parameter - new `mem::HashMap` takes explicit `Allocator&` parameter - add Codegen.pass1_arena and use for all `ZigValue` allocs - deinit Codegen.pass1_arena early in `zig_llvm_emit_output()` --- src/hash_map.hpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/hash_map.hpp') diff --git a/src/hash_map.hpp b/src/hash_map.hpp index e819ea1c10..69e5568093 100644 --- a/src/hash_map.hpp +++ b/src/hash_map.hpp @@ -19,7 +19,7 @@ public: init_capacity(capacity); } void deinit(void) { - free(_entries); + heap::c_allocator.deallocate(_entries, _capacity); } struct Entry { @@ -57,7 +57,7 @@ public: if (old_entry->used) internal_put(old_entry->key, old_entry->value); } - free(old_entries); + heap::c_allocator.deallocate(old_entries, old_capacity); } } @@ -164,7 +164,7 @@ private: void init_capacity(int capacity) { _capacity = capacity; - _entries = allocate(_capacity); + _entries = heap::c_allocator.allocate(_capacity); _size = 0; _max_distance_from_start_index = 0; for (int i = 0; i < _capacity; i += 1) { -- cgit v1.2.3