Add Allocator_Mode.Alloc_Non_Zerored

This commit is contained in:
gingerBill
2022-09-22 12:12:57 +01:00
parent eb0d7465e2
commit 7f601c9535
21 changed files with 128 additions and 65 deletions
+6 -3
View File
@@ -489,10 +489,13 @@ cmark_allocator_proc :: proc(allocator_data: rawptr, mode: runtime.Allocator_Mod
cmark_alloc := cast(^Allocator)allocator_data
switch mode {
case .Alloc:
case .Alloc, .Alloc_Non_Zeroed:
ptr := cmark_alloc.calloc(1, c.size_t(size))
res = transmute([]byte)runtime.Raw_Slice{ptr, size}
return res, nil
res = ([^]byte)(ptr)[:size]
if ptr == nil {
err = .Out_Of_Memory
}
return
case .Free:
cmark_alloc.free(old_memory)
+1 -1
View File
@@ -1564,7 +1564,7 @@ MemAllocatorProc :: proc(allocator_data: rawptr, mode: mem.Allocator_Mode,
size, alignment: int,
old_memory: rawptr, old_size: int, location := #caller_location) -> (data: []byte, err: mem.Allocator_Error) {
switch mode {
case .Alloc:
case .Alloc, .Alloc_Non_Zeroed:
ptr := MemAlloc(c.int(size))
if ptr == nil {
err = .Out_Of_Memory