-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_stack.h
More file actions
executable file
·43 lines (32 loc) · 832 Bytes
/
base_stack.h
File metadata and controls
executable file
·43 lines (32 loc) · 832 Bytes
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
40
41
42
43
#ifndef STACK_H
#define STACK_H
typedef struct mem_stack mem_stack;
typedef struct mem_stack_header mem_stack_header;
struct mem_stack
{
u8 *base_position;
umm current_offset;
umm capacity;
};
struct mem_stack_header
{
u8 padding;
u8 previous_offset;
};
internal mem_stack *
stack_create(u64 capacity);
internal umm
calculate_padding(umm pointer, umm alignment, umm header_size);
internal mem_stack *
stack_push_align(mem_stack *stack, u64 size, umm alignment);
internal void *
stack_push(mem_stack *stack, umm size);
internal void
stack_pop(mem_stack *stack, void *pointer);
internal mem_stack *
stack_resize_align(mem_stack *stack, void *pointer, u64 old_size, u64 new_size, u64 alignment);
internal void
stack_pop_all(mem_stack *stack);
internal void
stack_destroy(mem_stack *stack);
#endif