Init new repository
This commit is contained in:
28
examples/sandbox/arena_win32.lc
Normal file
28
examples/sandbox/arena_win32.lc
Normal file
@@ -0,0 +1,28 @@
|
||||
#build_if(LC_OS == OS_WINDOWS);
|
||||
|
||||
DWORD :: typedef u32;
|
||||
SIZE_T :: typedef uintptr;
|
||||
BOOL :: typedef int;
|
||||
|
||||
MEM_RESERVE :: 0x00002000;
|
||||
MEM_COMMIT :: 0x00001000;
|
||||
PAGE_READWRITE :: 0x04;
|
||||
VirtualAlloc :: proc(lpAddress: *void, dwSize: SIZE_T, flAllocationType: DWORD, flProtect: DWORD): *void; @api
|
||||
|
||||
MEM_RELEASE :: 0x00008000;
|
||||
MEM_DECOMMIT :: 0x00004000;
|
||||
VirtualFree :: proc(lpAddress: *void, dwSize: SIZE_T, dwFreeType: DWORD): BOOL; @api
|
||||
|
||||
VReserve :: proc(size: usize): *void {
|
||||
result := VirtualAlloc(nil, :SIZE_T(size), MEM_RESERVE, PAGE_READWRITE);
|
||||
return result;
|
||||
}
|
||||
|
||||
VCommit :: proc(p: *void, size: usize): bool {
|
||||
result := VirtualAlloc(p, :SIZE_T(size), MEM_COMMIT, PAGE_READWRITE) != 0;
|
||||
return result;
|
||||
}
|
||||
|
||||
VRelease :: proc(p: *void) {
|
||||
VirtualFree(p, 0, MEM_RELEASE);
|
||||
}
|
||||
Reference in New Issue
Block a user