Mercurial
comparison helper/helper.c @ 0:5695ef413be0
Initialized mono repo with bazels with few examples.
| author | June Park <parkjune1995@gmail.com> |
|---|---|
| date | Tue, 23 Sep 2025 10:05:25 -0700 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:5695ef413be0 |
|---|---|
| 1 #include "helper.h" | |
| 2 | |
| 3 void ArenaIntialize(PArena p_arena, size_t capacity) | |
| 4 { | |
| 5 p_arena = malloc(capacity); | |
| 6 p_arena->offset = 0; | |
| 7 p_arena->capacity = capacity; | |
| 8 } | |
| 9 | |
| 10 void *ArenaAllocate(PArena p_arena, size_t size) | |
| 11 { | |
| 12 if (p_arena->offset + size > p_arena->capacity) | |
| 13 { | |
| 14 return NULL; | |
| 15 } | |
| 16 void *currnet_ptr = p_arena->buffer + p_arena->offset; | |
| 17 p_arena->offset += size; | |
| 18 return currnet_ptr; | |
| 19 } | |
| 20 | |
| 21 void *ArenaFree(PArena p_arena) | |
| 22 { | |
| 23 if (p_arena) { | |
| 24 free(p_arena->buffer); | |
| 25 free(p_arena); | |
| 26 } | |
| 27 return; | |
| 28 } |