mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 07:38:48 +00:00
Correct mmap usage
This commit is contained in:
@@ -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) {
|
_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)
|
result := mmap(nil, size, PROT_NONE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
|
||||||
if result == nil {
|
if result == MAP_FAILED {
|
||||||
err = .Out_Of_Memory
|
return nil, .Out_Of_Memory
|
||||||
return
|
|
||||||
}
|
}
|
||||||
data = ([^]byte)(result)[:size]
|
return ([^]byte)(result)[:size], nil
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_commit :: proc(data: rawptr, size: uint) {
|
_commit :: proc(data: rawptr, size: uint) {
|
||||||
|
|||||||
Reference in New Issue
Block a user