blob: 78a1d35367832616290ec54149fdbdc4f356ec0e (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#ifndef BASE_STACK_WIN32_H
#define BASE_STACK_WIN32_H
// request a page from the operating system
internal MemStack *
win32_stack_create(u64 capacity)
{
MemStack *stack = (MemStack *)VirtualAlloc(
NULL,
capacity + sizeof(MemStack),
MEM_COMMIT | MEM_RESERVE,
PAGE_READWRITE);
if(!stack)
{
Log("Failed to receive a memory adress from the operating system");
return NULL;
}
stack->capacity = capacity;
stack->base_position = (u8 *)stack + sizeof(MemStack);
stack->current_offset = 0;
return stack;
}
internal void *
win32_stack_destroy(MemStack *stack)
{
b32 result = VirtualFree(stack,
0, // stands for the byte of commited pages
MEM_RELEASE);
if(!result)
{
Log("Failed to receive a memory adress from the operating system");
}
}
#endif /* BASE_STACK_WIN32_H */
|