From aa8777ee47f503eb90d4e2225274d0d20a9b39a3 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 26 Aug 2021 15:38:34 +0100 Subject: Change the implementation of `Arena` to use virtual memory, and remove the old gbArena code --- src/build_settings.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'src/build_settings.cpp') diff --git a/src/build_settings.cpp b/src/build_settings.cpp index f58ac84a2..841870fec 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -500,7 +500,6 @@ String odin_root_dir(void) { String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; - gbTempArenaMemory tmp; wchar_t *text; if (global_module_path_set) { @@ -525,10 +524,7 @@ String internal_odin_root_dir(void) { mutex_lock(&string_buffer_mutex); defer (mutex_unlock(&string_buffer_mutex)); - tmp = gb_temp_arena_memory_begin(&string_buffer_arena); - defer (gb_temp_arena_memory_end(tmp)); - - text = gb_alloc_array(string_buffer_allocator, wchar_t, len+1); + text = gb_alloc_array(permanent_allocator(), wchar_t, len+1); GetModuleFileNameW(nullptr, text, cast(int)len); path = string16_to_string(heap_allocator(), make_string16(text, len)); @@ -559,7 +555,6 @@ String path_to_fullpath(gbAllocator a, String s); String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; - gbTempArenaMemory tmp; u8 *text; if (global_module_path_set) { @@ -583,10 +578,7 @@ String internal_odin_root_dir(void) { mutex_lock(&string_buffer_mutex); defer (mutex_unlock(&string_buffer_mutex)); - tmp = gb_temp_arena_memory_begin(&string_buffer_arena); - defer (gb_temp_arena_memory_end(tmp)); - - text = gb_alloc_array(string_buffer_allocator, u8, len + 1); + text = gb_alloc_array(permanent_allocator(), u8, len + 1); gb_memmove(text, &path_buf[0], len); path = path_to_fullpath(heap_allocator(), make_string(text, len)); @@ -663,7 +655,7 @@ String internal_odin_root_dir(void) { tmp = gb_temp_arena_memory_begin(&string_buffer_arena); defer (gb_temp_arena_memory_end(tmp)); - text = gb_alloc_array(string_buffer_allocator, u8, len + 1); + text = gb_alloc_array(permanent_allocator(), u8, len + 1); gb_memmove(text, &path_buf[0], len); @@ -691,13 +683,11 @@ String path_to_fullpath(gbAllocator a, String s) { mutex_lock(&fullpath_mutex); defer (mutex_unlock(&fullpath_mutex)); - gbTempArenaMemory tmp = gb_temp_arena_memory_begin(&string_buffer_arena); - defer (gb_temp_arena_memory_end(tmp)); - String16 string16 = string_to_string16(string_buffer_allocator, s); + String16 string16 = string_to_string16(temporary_allocator(), s); DWORD len = GetFullPathNameW(&string16[0], 0, nullptr, nullptr); if (len != 0) { - wchar_t *text = gb_alloc_array(string_buffer_allocator, wchar_t, len+1); + wchar_t *text = gb_alloc_array(permanent_allocator(), wchar_t, len+1); GetFullPathNameW(&string16[0], len, text, nullptr); text[len] = 0; result = string16_to_string(a, make_string16(text, len)); -- cgit v1.2.3 From 3e4d615983f76616b5a598b89b75aa84975a4aab Mon Sep 17 00:00:00 2001 From: gingerBill Date: Thu, 26 Aug 2021 15:41:32 +0100 Subject: Minor fixes --- src/build_settings.cpp | 4 ---- src/common.cpp | 6 +++++- src/common_memory.cpp | 8 +------- 3 files changed, 6 insertions(+), 12 deletions(-) (limited to 'src/build_settings.cpp') diff --git a/src/build_settings.cpp b/src/build_settings.cpp index 841870fec..f3cc45ae8 100644 --- a/src/build_settings.cpp +++ b/src/build_settings.cpp @@ -609,7 +609,6 @@ String path_to_fullpath(gbAllocator a, String s); String internal_odin_root_dir(void) { String path = global_module_path; isize len, i; - gbTempArenaMemory tmp; u8 *text; if (global_module_path_set) { @@ -652,9 +651,6 @@ String internal_odin_root_dir(void) { mutex_lock(&string_buffer_mutex); defer (mutex_unlock(&string_buffer_mutex)); - tmp = gb_temp_arena_memory_begin(&string_buffer_arena); - defer (gb_temp_arena_memory_end(tmp)); - text = gb_alloc_array(permanent_allocator(), u8, len + 1); gb_memmove(text, &path_buf[0], len); diff --git a/src/common.cpp b/src/common.cpp index eeadc71bc..af0a195a8 100644 --- a/src/common.cpp +++ b/src/common.cpp @@ -33,8 +33,12 @@ gbAllocator heap_allocator(void); #define for_array(index_, array_) for (isize index_ = 0; index_ < (array_).count; index_++) -#include "threading.cpp" +i32 next_pow2(i32 n); +i64 next_pow2(i64 n); +isize next_pow2_isize(isize n); +void debugf(char const *fmt, ...); +#include "threading.cpp" #include "unicode.cpp" #include "array.cpp" #include "queue.cpp" diff --git a/src/common_memory.cpp b/src/common_memory.cpp index ef46dcaa6..afdcb2dee 100644 --- a/src/common_memory.cpp +++ b/src/common_memory.cpp @@ -6,11 +6,6 @@ gb_inline void zero_size(void *ptr, isize len) { #define zero_item(ptr) zero_size((ptr), gb_size_of(ptr)) -i32 next_pow2(i32 n); -i64 next_pow2(i64 n); -isize next_pow2_isize(isize n); -void debugf(char const *fmt, ...); - template gb_inline U bit_cast(V &v) { return reinterpret_cast(v); } @@ -64,7 +59,6 @@ struct MemoryBlock { struct Arena { MemoryBlock * curr_block; isize minimum_block_size; - isize temporary_memory_count; }; enum { DEFAULT_MINIMUM_BLOCK_SIZE = 8ll*1024ll*1024ll }; @@ -213,7 +207,7 @@ void platform_virtual_memory_init(void) { } -MemoryBlock *virtual_memory_alloc(isize size, MemoryBlockFlags flags) { +MemoryBlock *virtual_memory_alloc(isize size) { return nullptr; } -- cgit v1.2.3