mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Add asan support for various allocators
This commit is contained in:
@@ -83,6 +83,8 @@ foreign Kernel32 {
|
||||
dwNumberOfBytesToMap: uint,
|
||||
) -> rawptr ---
|
||||
}
|
||||
|
||||
@(no_sanitize_address)
|
||||
_reserve :: proc "contextless" (size: uint) -> (data: []byte, err: Allocator_Error) {
|
||||
result := VirtualAlloc(nil, size, MEM_RESERVE, PAGE_READWRITE)
|
||||
if result == nil {
|
||||
@@ -93,6 +95,7 @@ _reserve :: proc "contextless" (size: uint) -> (data: []byte, err: Allocator_Err
|
||||
return
|
||||
}
|
||||
|
||||
@(no_sanitize_address)
|
||||
_commit :: proc "contextless" (data: rawptr, size: uint) -> Allocator_Error {
|
||||
result := VirtualAlloc(data, size, MEM_COMMIT, PAGE_READWRITE)
|
||||
if result == nil {
|
||||
@@ -107,12 +110,18 @@ _commit :: proc "contextless" (data: rawptr, size: uint) -> Allocator_Error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@(no_sanitize_address)
|
||||
_decommit :: proc "contextless" (data: rawptr, size: uint) {
|
||||
VirtualFree(data, size, MEM_DECOMMIT)
|
||||
}
|
||||
|
||||
@(no_sanitize_address)
|
||||
_release :: proc "contextless" (data: rawptr, size: uint) {
|
||||
VirtualFree(data, 0, MEM_RELEASE)
|
||||
}
|
||||
|
||||
@(no_sanitize_address)
|
||||
_protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags) -> bool {
|
||||
pflags: u32
|
||||
pflags = PAGE_NOACCESS
|
||||
@@ -136,7 +145,7 @@ _protect :: proc "contextless" (data: rawptr, size: uint, flags: Protect_Flags)
|
||||
}
|
||||
|
||||
|
||||
|
||||
@(no_sanitize_address)
|
||||
_platform_memory_init :: proc() {
|
||||
sys_info: SYSTEM_INFO
|
||||
GetSystemInfo(&sys_info)
|
||||
@@ -147,6 +156,7 @@ _platform_memory_init :: proc() {
|
||||
}
|
||||
|
||||
|
||||
@(no_sanitize_address)
|
||||
_map_file :: proc "contextless" (fd: uintptr, size: i64, flags: Map_File_Flags) -> (data: []byte, error: Map_File_Error) {
|
||||
page_flags: u32
|
||||
if flags == {.Read} {
|
||||
|
||||
Reference in New Issue
Block a user