Getting rid of heap stuff completely but also naively
This commit is contained in:
@@ -248,56 +248,3 @@ os_list_dir(Allocator *a, String dir, U32 flags = LIST_NO_FLAGS){
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// OS Heap allocator
|
||||
//-----------------------------------------------------------------------------
|
||||
struct OS_Heap:Allocator{
|
||||
void *handle;
|
||||
};
|
||||
|
||||
function void *
|
||||
os_heap_allocator_proc(Allocator *a, Allocation_Kind kind, void *old_pointer, size_t size){
|
||||
OS_Heap *heap = (OS_Heap *)a;
|
||||
switch(kind){
|
||||
case Allocation_FreeAll:{
|
||||
invalid_codepath;
|
||||
return 0;
|
||||
}
|
||||
case Allocation_Destroy:{
|
||||
BOOL result = HeapDestroy(heap->handle);
|
||||
assert(result != 0);
|
||||
heap->handle = 0;
|
||||
heap->proc = 0;
|
||||
return 0;
|
||||
}
|
||||
case Allocation_Free:{
|
||||
BOOL result = HeapFree(heap->handle, 0, old_pointer);
|
||||
assert(result != 0);
|
||||
return 0;
|
||||
}
|
||||
case Allocation_Alloc:{
|
||||
void *result = HeapAlloc(heap->handle, 0, size);
|
||||
assert(result);
|
||||
return result;
|
||||
}
|
||||
case Allocation_Resize:{
|
||||
void *result = HeapReAlloc(heap->handle, 0, old_pointer, size);
|
||||
assert(result);
|
||||
return result;
|
||||
}
|
||||
default: invalid_codepath;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
function OS_Heap // max_size == 0 == growing heap
|
||||
win32_os_heap_create(B32 multithreaded, size_t initial_size, size_t max_size, String debug_name){
|
||||
OS_Heap result = {};
|
||||
result.debug_name = debug_name;
|
||||
result.proc = os_heap_allocator_proc;
|
||||
result.kind = Allocator_OSHeap;
|
||||
result.handle = HeapCreate(multithreaded ? 0 : HEAP_NO_SERIALIZE, initial_size, max_size);
|
||||
assert(result.handle);
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user