#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);
}