diff options
author | Michael Pavone <pavone@retrodev.com> | 2016-07-17 23:05:53 -0700 |
---|---|---|
committer | Michael Pavone <pavone@retrodev.com> | 2016-07-17 23:05:53 -0700 |
commit | e36472320049c15f929b52e9d32df397aeab6699 (patch) | |
tree | e84c2d5ab8101e1daaeaaa8a0370d8bf621eaaf0 /arena.c | |
parent | 809fa1647637a728d1bed9bd4ef078047cab60f9 (diff) | |
parent | 73cd2eca0ecead1cc8341305a6eb1988f818526e (diff) |
Merge
Diffstat (limited to 'arena.c')
-rw-r--r-- | arena.c | 8 |
1 files changed, 7 insertions, 1 deletions
@@ -17,6 +17,8 @@ struct arena { size_t free_storage; }; +#define DEFAULT_STORAGE_SIZE 8 + static arena *current_arena; arena *get_current_arena() @@ -45,7 +47,11 @@ void track_block(void *block) { arena *cur = get_current_arena(); if (cur->used_count == cur->used_storage) { - cur->used_storage *= 2; + if (cur->used_storage) { + cur->used_storage *= 2; + } else { + cur->used_storage = DEFAULT_STORAGE_SIZE; + } cur->used_blocks = realloc(cur->used_blocks, cur->used_storage * sizeof(void *)); } cur->used_blocks[cur->used_count++] = block; |