Getting rid of heap stuff completely but also naively
This commit is contained in:
63
base.cpp
63
base.cpp
@@ -588,30 +588,6 @@ arena_allocator_proc(Allocator *a, Allocation_Kind kind, void *old_pointer, size
|
||||
return 0;
|
||||
}
|
||||
|
||||
force_inline void *
|
||||
personal_arena_allocator_proc(Allocator *a, Allocation_Kind kind, void *old_pointer, size_t size){
|
||||
Arena *arena = (Arena *)a;
|
||||
arena->alignment = 1;
|
||||
|
||||
void *result = 0;
|
||||
switch(kind){
|
||||
case Allocation_Resize: {
|
||||
assert(arena->old_size);
|
||||
assert(arena->old_size < size);
|
||||
assert(arena->debug_prev_pointer == old_pointer);
|
||||
result = arena_push_size(arena, size - arena->old_size);
|
||||
result = old_pointer;
|
||||
} break;
|
||||
default: {
|
||||
result = arena_allocator_proc(a, kind, old_pointer, size);
|
||||
arena->debug_prev_pointer = result;
|
||||
}
|
||||
}
|
||||
|
||||
arena->old_size = size;
|
||||
return result;
|
||||
}
|
||||
|
||||
function void
|
||||
arena_init(Arena *a, String debug_name){
|
||||
a->memory = os_reserve(default_reserve_size);
|
||||
@@ -621,15 +597,6 @@ arena_init(Arena *a, String debug_name){
|
||||
if(!a->proc) a->proc = arena_allocator_proc;
|
||||
}
|
||||
|
||||
function Arena
|
||||
arena_make_personal(String debug_name){
|
||||
Arena arena = {};
|
||||
arena.proc = personal_arena_allocator_proc;
|
||||
arena_init(&arena, debug_name);
|
||||
arena.kind = Allocator_PersonalArena;
|
||||
return arena;
|
||||
}
|
||||
|
||||
enum Log_Kind{Log_Kind_Normal, Log_Kind_Error, Log_Kind_Trace};
|
||||
typedef void Log_Proc(Log_Kind kind, String string, char *file, int line);
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -892,35 +859,6 @@ array_make(Allocator *a, S64 size = 16){
|
||||
return result;
|
||||
}
|
||||
|
||||
function void
|
||||
test_array(){
|
||||
Scratch scratch;
|
||||
Array<int> array = {scratch};
|
||||
|
||||
int size = 1000;
|
||||
for(int i = 0; i < size; i++){
|
||||
array.add(i);
|
||||
}
|
||||
S32 i = 0;
|
||||
For(array){
|
||||
assert(it == i++);
|
||||
}
|
||||
|
||||
Arena arena = arena_make_personal("Test personal arena"_s);
|
||||
Array<int> array2 = {&arena};
|
||||
for(int i = 0; i < size; i++){
|
||||
array2.add(i);
|
||||
}
|
||||
i=0;
|
||||
For(array2){
|
||||
assert(it == i++);
|
||||
}
|
||||
exp_destroy(&arena);
|
||||
assert(arena.memory.data == 0);
|
||||
assert(thread_ctx.scratch->memory.data != 0);
|
||||
}
|
||||
|
||||
|
||||
#include "base_string.cpp"
|
||||
//-----------------------------------------------------------------------------
|
||||
// Logging
|
||||
@@ -1042,7 +980,6 @@ function Map_Key_Value *
|
||||
map_base_get(Map *map, U64 key){
|
||||
if(map->len == 0) return 0;
|
||||
assert(key);
|
||||
// if(key == 0) key+=1;
|
||||
|
||||
U64 hash = hash_u64(key);
|
||||
U64 index = wrap_around_pow2(hash, map->cap);
|
||||
|
||||
Reference in New Issue
Block a user