diff options
| author | @syxhe <https://t.me/syxhe> | 2025-05-14 12:19:34 -0500 |
|---|---|---|
| committer | @syxhe <https://t.me/syxhe> | 2025-05-14 12:19:34 -0500 |
| commit | 928238bdcbc78c4196eb4a3508808c79e31f7c84 (patch) | |
| tree | 6ce7c393be64ba26c54f9f5f8d3fa442c6f5833d /src/arena.c | |
| parent | 9be8b5f26a29dad04035386331461c4c320f9237 (diff) | |
Update signatures of free-type functions to match the freecallback signature
Diffstat (limited to 'src/arena.c')
| -rw-r--r-- | src/arena.c | 50 |
1 files changed, 15 insertions, 35 deletions
diff --git a/src/arena.c b/src/arena.c index f944661..40c72d5 100644 --- a/src/arena.c +++ b/src/arena.c | |||
| @@ -103,42 +103,25 @@ void * arena_alloc(arena * const arena, size_t bytes) { | |||
| 103 | // doesn't, that sucks and blows everything up | 103 | // doesn't, that sucks and blows everything up |
| 104 | } | 104 | } |
| 105 | 105 | ||
| 106 | int arena_free(arena **arena) { | 106 | void arena_free(void *a) { |
| 107 | if(!arena) | 107 | if(!a) |
| 108 | RETURNWERR(EINVAL, -1); | 108 | return; |
| 109 | if(!(*arena)) | ||
| 110 | RETURNWERR(EINVAL, -1); | ||
| 111 | 109 | ||
| 112 | (*arena)->current = (*arena)->start; | 110 | arena *real = (arena *)a; |
| 113 | for(arenanode *n; (*arena)->current != NULL;) { | 111 | real->current = real->start; |
| 114 | n = (*arena)->current->next; | 112 | for(arenanode *n; real->current != NULL;) { |
| 113 | n = real->current->next; | ||
| 115 | 114 | ||
| 116 | free((*arena)->current->membase); | 115 | free(real->current->membase); |
| 117 | free((*arena)->current); | 116 | free(real->current); |
| 118 | 117 | ||
| 119 | (*arena)->current = n; | 118 | real->current = n; |
| 120 | } | 119 | } |
| 121 | free((*arena)); | 120 | free(real); |
| 122 | (*arena) = NULL; | ||
| 123 | 121 | ||
| 124 | return 0; | 122 | return; |
| 125 | } | 123 | } |
| 126 | 124 | ||
| 127 | int arena_clear(arena **arena) { | ||
| 128 | if(!arena) | ||
| 129 | RETURNWERR(EINVAL, -1); | ||
| 130 | if(!(*arena)) | ||
| 131 | RETURNWERR(EINVAL, -1); | ||
| 132 | |||
| 133 | size_t bytes = (*arena)->node_memspace; | ||
| 134 | |||
| 135 | int ret = 0; | ||
| 136 | if((ret = arena_free(arena)) < 0) | ||
| 137 | return ret; | ||
| 138 | (*arena) = arena_init(bytes); | ||
| 139 | |||
| 140 | return (!(*arena)) ? -1 : 0; | ||
| 141 | } | ||
| 142 | 125 | ||
| 143 | 126 | ||
| 144 | 127 | ||
| @@ -158,10 +141,7 @@ void * simplearena_alloc(simplearena * const a, size_t bytes) { | |||
| 158 | return arena_alloc(a, bytes); | 141 | return arena_alloc(a, bytes); |
| 159 | } | 142 | } |
| 160 | 143 | ||
| 161 | int simplearena_free(simplearena **a) { | 144 | void simplearena_free(simplearena *a) { |
| 162 | return arena_free(a); | 145 | arena_free(a); |
| 163 | } | 146 | return; |
| 164 | |||
| 165 | int simplearena_clear(simplearena **a) { | ||
| 166 | return arena_clear(a); | ||
| 167 | } \ No newline at end of file | 147 | } \ No newline at end of file |
