aboutsummaryrefslogtreecommitdiff
path: root/src/std/buffer.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/std/buffer.c')
-rw-r--r--src/std/buffer.c8
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;