aboutsummaryrefslogtreecommitdiff
path: root/src/utils.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils.c')
-rw-r--r--src/utils.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/utils.c b/src/utils.c
index 354159b..1baf283 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1,5 +1,8 @@
#include "utils.h"
+#include <stdio.h>
+#include <assert.h>
+
struct allocator {
void** bufs;
size_t cap;
@@ -19,10 +22,12 @@ void deleteAllocator(Allocator alct) {
for (size_t i = 0; i < alct->len; i++) {
free(alct->bufs[i]);
}
+ free(alct->bufs);
free(alct);
}
void * allocate(Allocator alct, size_t size) {
+ assert(size > 0);
if (alct->len >= alct->cap) {
alct->cap = alct->cap * 2; // Doubling the capacity
alct->bufs = realloc(alct->bufs, sizeof(void*) * alct->cap);