aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authordec05eba <dec05eba@protonmail.com>2019-04-25 23:32:23 +0200
committerdec05eba <dec05eba@protonmail.com>2020-07-25 14:36:46 +0200
commit1b68fdcf5aebf2bc53bbd9234c77aea243c0decd (patch)
tree1a26f5b5ab32e6b435fa2afca789a5b846d11f46 /include
parent7f524c427597cc998f243769b0e22e4f450c55cf (diff)
Fix scoped allocator deinit crash with buffers
Diffstat (limited to 'include')
-rw-r--r--include/std/buffer.h3
-rw-r--r--include/std/scoped_allocator.h4
2 files changed, 5 insertions, 2 deletions
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/*<void*>*/ mems;
/* TODO: Use linked-list instead, since the elements are dynamically allocated anyways */
/* Find another way to store mutexes */
- Buffer/*<Buffer*>*/ buffers;
Buffer/*<amal_mutex*>*/ 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