diff options
author | dec05eba <dec05eba@protonmail.com> | 2019-07-17 19:23:16 +0200 |
---|---|---|
committer | dec05eba <dec05eba@protonmail.com> | 2020-07-25 14:36:46 +0200 |
commit | 84e65c63e7482590d535e86f7660a00ae8a0cecb (patch) | |
tree | c79de87b7136e96b977003db85d43e5e676bbfc1 /src/std/buffer.c | |
parent | 85c654a102701958d3748e82ecac9c1bc4dbbcba (diff) |
Start on amal program
Fix mutex issue in lhs expr which can cause a deadlock when a file has
an error and throws and doesn't close the mutex and another thread waits
for that mutex. The mutex can instead be removed and ignore race
conditions which are uncommon. This should improve memory usage and
performance.
Diffstat (limited to 'src/std/buffer.c')
-rw-r--r-- | src/std/buffer.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/std/buffer.c b/src/std/buffer.c index 3676cee..f4e93e5 100644 --- a/src/std/buffer.c +++ b/src/std/buffer.c @@ -17,6 +17,14 @@ int buffer_init(Buffer *self, struct ScopedAllocator *allocator) { } } +void buffer_deinit(Buffer *self) { + assert(!self->allocator && "Can't deinit buffer if it has an allocator"); + am_free(self->data); + self->data = NULL; + self->size = 0; + self->capacity = 0; +} + static CHECK_RESULT int buffer_ensure_capacity(Buffer *self, usize new_capacity) { usize capacity; void *new_mem; |