diff options
| author | @syxhe <https://t.me/syxhe> | 2025-03-25 18:13:14 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2025-03-25 18:13:14 -0500 |
| commit | cfdd25cdd8efabaa43446036e0ff0c326c001f8f (patch) | |
| tree | 15402876239f5aa6d018fb662ab94f85f81e9277 /src/main.c | |
| parent | 277e3b7dd1bc85cd190c6e4c451c7bfab71ee07e (diff) | |
Change function signature of (simple)arena_init function
Diffstat (limited to 'src/main.c')
| -rw-r--r-- | src/main.c | 22 |
1 files changed, 21 insertions, 1 deletions
| @@ -7,8 +7,28 @@ | |||
| 7 | #include <error.h> | 7 | #include <error.h> |
| 8 | #include <stdio.h> | 8 | #include <stdio.h> |
| 9 | 9 | ||
| 10 | #include <string.h> | ||
| 11 | #include <stdlib.h> | ||
| 10 | int main() { | 12 | int main() { |
| 11 | error(1, ENOTSUP, "No main file lol"); | 13 | // error(1, ENOTSUP, "No main file lol"); |
| 14 | |||
| 15 | // Testing Arena changes | ||
| 16 | const int DATA[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}; | ||
| 17 | |||
| 18 | arena *arena = arena_init(sizeof(DATA)); | ||
| 19 | if(!arena) | ||
| 20 | error(1, errno, "Could not initialize arena"); | ||
| 21 | |||
| 22 | int *nums = arena_alloc(arena, sizeof(DATA)); | ||
| 23 | if(!nums) | ||
| 24 | error(1, errno, "Could not allocate memory"); | ||
| 25 | |||
| 26 | memmove(nums, DATA, sizeof(DATA)); | ||
| 27 | for(unsigned int i = 0; i < STATIC_ARRAY_LEN(DATA); i++) | ||
| 28 | printf("%d ", nums[i]); | ||
| 29 | printf("\n"); | ||
| 30 | |||
| 31 | arena_free(&arena); | ||
| 12 | 32 | ||
| 13 | return 0; | 33 | return 0; |
| 14 | } \ No newline at end of file | 34 | } \ No newline at end of file |
