aboutsummaryrefslogtreecommitdiff
path: root/base/runtime/heap_allocator_windows.odin
diff options
context:
space:
mode:
Diffstat (limited to 'base/runtime/heap_allocator_windows.odin')
-rw-r--r--base/runtime/heap_allocator_windows.odin49
1 files changed, 25 insertions, 24 deletions
diff --git a/base/runtime/heap_allocator_windows.odin b/base/runtime/heap_allocator_windows.odin
index 1c521c42f..2097c3671 100644
--- a/base/runtime/heap_allocator_windows.odin
+++ b/base/runtime/heap_allocator_windows.odin
@@ -5,34 +5,35 @@ foreign import kernel32 "system:Kernel32.lib"
@(private="file")
@(default_calling_convention="system")
foreign kernel32 {
- // NOTE(bill): The types are not using the standard names (e.g. DWORD and LPVOID) to just minimizing the dependency
+ // NOTE(bill): The types are not using the standard names (e.g. DWORD and LPVOID) to just minimizing the dependency
- // default_allocator
- GetProcessHeap :: proc() -> rawptr ---
- HeapAlloc :: proc(hHeap: rawptr, dwFlags: u32, dwBytes: uint) -> rawptr ---
- HeapReAlloc :: proc(hHeap: rawptr, dwFlags: u32, lpMem: rawptr, dwBytes: uint) -> rawptr ---
- HeapFree :: proc(hHeap: rawptr, dwFlags: u32, lpMem: rawptr) -> b32 ---
+ // default_allocator
+ GetProcessHeap :: proc() -> rawptr ---
+ HeapAlloc :: proc(hHeap: rawptr, dwFlags: u32, dwBytes: uint) -> rawptr ---
+ HeapReAlloc :: proc(hHeap: rawptr, dwFlags: u32, lpMem: rawptr, dwBytes: uint) -> rawptr ---
+ HeapFree :: proc(hHeap: rawptr, dwFlags: u32, lpMem: rawptr) -> b32 ---
}
-heap_alloc :: proc "contextless" (size: int, zero_memory := true) -> rawptr {
- HEAP_ZERO_MEMORY :: 0x00000008
- return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY if zero_memory else 0, uint(size))
+_heap_alloc :: proc(size: int, zero_memory := true) -> rawptr {
+ HEAP_ZERO_MEMORY :: 0x00000008
+ return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY if zero_memory else 0, uint(size))
}
-heap_resize :: proc "contextless" (ptr: rawptr, new_size: int) -> rawptr {
- if new_size == 0 {
- heap_free(ptr)
- return nil
- }
- if ptr == nil {
- return heap_alloc(new_size)
- }
+_heap_resize :: proc(ptr: rawptr, new_size: int) -> rawptr {
+ if new_size == 0 {
+ _heap_free(ptr)
+ return nil
+ }
+ if ptr == nil {
+ return _heap_alloc(new_size)
+ }
- HEAP_ZERO_MEMORY :: 0x00000008
- return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ptr, uint(new_size))
+ HEAP_ZERO_MEMORY :: 0x00000008
+ return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ptr, uint(new_size))
}
-heap_free :: proc "contextless" (ptr: rawptr) {
- if ptr == nil {
- return
- }
- HeapFree(GetProcessHeap(), 0, ptr)
+_heap_free :: proc(ptr: rawptr) {
+ if ptr == nil {
+ return
+ }
+ HeapFree(GetProcessHeap(), 0, ptr)
}
+