From 1b68fdcf5aebf2bc53bbd9234c77aea243c0decd Mon Sep 17 00:00:00 2001 From: dec05eba Date: Thu, 25 Apr 2019 23:32:23 +0200 Subject: Fix scoped allocator deinit crash with buffers --- include/std/buffer.h | 3 +++ include/std/scoped_allocator.h | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/std/buffer.h b/include/std/buffer.h index aa82bcc..af6b986 100644 --- a/include/std/buffer.h +++ b/include/std/buffer.h @@ -12,6 +12,9 @@ typedef struct { char* data; usize size; usize capacity; + + ScopedAllocator *allocator; + usize allocator_index; } Buffer; CHECK_RESULT int buffer_init(Buffer *self, struct ScopedAllocator *allocator); diff --git a/include/std/scoped_allocator.h b/include/std/scoped_allocator.h index d7ec1e1..60abcce 100644 --- a/include/std/scoped_allocator.h +++ b/include/std/scoped_allocator.h @@ -15,9 +15,9 @@ struct ScopedAllocatorNode { struct ScopedAllocator { ScopedAllocatorNode head; ScopedAllocatorNode *current; + Buffer/**/ mems; /* TODO: Use linked-list instead, since the elements are dynamically allocated anyways */ /* Find another way to store mutexes */ - Buffer/**/ buffers; Buffer/**/ mutexes; }; @@ -27,7 +27,7 @@ void scoped_allocator_node_deinit(ScopedAllocatorNode *self); CHECK_RESULT int scoped_allocator_init(ScopedAllocator *self); void scoped_allocator_deinit(ScopedAllocator *self); CHECK_RESULT int scoped_allocator_alloc(ScopedAllocator *self, usize size, void **mem); -CHECK_RESULT int scoped_allocator_add_buffer(ScopedAllocator *self, Buffer *buffer); +CHECK_RESULT int scoped_allocator_add_mem(ScopedAllocator *self, usize *result_index); CHECK_RESULT int scoped_allocator_create_mutex(ScopedAllocator *self, amal_mutex **mutex); #endif -- cgit v1.2.3