Correct mmap usage

This commit is contained in:
gingerBill
2021-10-05 17:05:33 +01:00
parent 1f1434b384
commit 16ca677c1f
+4 -5
View File
@@ -67,13 +67,12 @@ madvise :: proc "contextless" (addr: rawptr, length: uint, advice: c.int) -> c.i
_reserve :: proc(size: uint) -> (data: []byte, err: Allocator_Error) {
MAP_FAILED := rawptr(uintptr(~0))
result := mmap(nil, size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
if result == nil {
err = .Out_Of_Memory
return
if result == MAP_FAILED {
return nil, .Out_Of_Memory
}
data = ([^]byte)(result)[:size]
return
return ([^]byte)(result)[:size], nil
}
_commit :: proc(data: rawptr, size: uint) {