Disable aligned heap allocations hack in os.heap_allocator_proc

This commit is contained in:
gingerBill
2019-12-01 18:53:27 +00:00
parent 46582a45bd
commit ebe152a155
+20
View File
@@ -122,6 +122,7 @@ read_ptr :: proc(fd: Handle, data: rawptr, len: int) -> (int, Errno) {
heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
size, alignment: int,
old_memory: rawptr, old_size: int, flags: u64 = 0, loc := #caller_location) -> rawptr {
/*
//
// NOTE(tetra, 2019-11-10): The heap doesn't respect alignment.
// HACK: Overallocate, align forwards, and then use the two bytes immediately before
@@ -183,6 +184,25 @@ heap_allocator_proc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
return align_and_store_padding(ptr, alignment);
}
return nil;
*/
switch mode {
case .Alloc:
return heap_alloc(size);
case .Free:
if old_memory != nil {
heap_free(old_memory);
}
return nil;
case .Free_All:
// NOTE(bill): Does nothing
case .Resize:
return heap_resize(ptr, size);
}
return nil;
}