diff options
Diffstat (limited to 'src/std/scoped_allocator.c')
-rw-r--r-- | src/std/scoped_allocator.c | 30 |
1 files changed, 1 insertions, 29 deletions
diff --git a/src/std/scoped_allocator.c b/src/std/scoped_allocator.c index 84ec920..d8acbf6 100644 --- a/src/std/scoped_allocator.c +++ b/src/std/scoped_allocator.c @@ -27,15 +27,7 @@ void scoped_allocator_node_deinit(ScopedAllocatorNode *self) { int scoped_allocator_init(ScopedAllocator *self) { return_if_error(scoped_allocator_node_init(&self->head)); self->current = &self->head; - return_if_error(buffer_init(&self->mems, NULL)); - return buffer_init(&self->mutexes, NULL); -} - -static void buffer_deinit(Buffer *self) { - am_free(self->data); - self->data = NULL; - self->size = 0; - self->capacity = 0; + return buffer_init(&self->mems, NULL); } static void scoped_allocator_deinit_buffers(ScopedAllocator *self) { @@ -50,22 +42,9 @@ static void scoped_allocator_deinit_buffers(ScopedAllocator *self) { buffer_deinit(&self->mems); } -static void scoped_allocator_deinit_mutexes(ScopedAllocator *self) { - amal_mutex **mutex; - amal_mutex **mutexes_end; - mutex = buffer_begin(&self->mutexes); - mutexes_end = buffer_end(&self->mutexes); - while(mutex != mutexes_end) { - amal_mutex_deinit(*mutex); - ++mutex; - } - buffer_deinit(&self->mutexes); -} - void scoped_allocator_deinit(ScopedAllocator *self) { self->current = NULL; scoped_allocator_deinit_buffers(self); - scoped_allocator_deinit_mutexes(self); scoped_allocator_node_deinit(&self->head); } @@ -129,10 +108,3 @@ int scoped_allocator_add_mem(ScopedAllocator *self, usize *result_index) { *result_index = buffer_get_size(&self->mems, sizeof(void*)); return buffer_append(&self->mems, &null_data, sizeof(void*)); } - -int scoped_allocator_create_mutex(ScopedAllocator *self, amal_mutex **mutex) { - *mutex = NULL; - return_if_error(scoped_allocator_alloc(self, sizeof(amal_mutex), (void**)mutex)); - amal_mutex_init(*mutex); - return buffer_append(&self->mutexes, mutex, sizeof(amal_mutex*)); -} |