diff options
Diffstat (limited to 'src/allocator.c')
| -rw-r--r-- | src/allocator.c | 24 |
1 files changed, 0 insertions, 24 deletions
diff --git a/src/allocator.c b/src/allocator.c deleted file mode 100644 index 308b97c..0000000 --- a/src/allocator.c +++ /dev/null @@ -1,24 +0,0 @@ -#include "allocator.h" - -struct frame_allocator frame_allocator_create(size_t capacity) { - return (struct frame_allocator){ - .capacity = capacity, .offset = 0, .buf = (uint8_t *)malloc(capacity)}; -} - -void frame_allocator_destroy(struct frame_allocator *alloc) { - free(alloc->buf); - alloc->buf = NULL; -} - -void *frame_allocator_alloc(struct frame_allocator *alloc, size_t sz) { - if (alloc->offset + sz > alloc->capacity) { - return NULL; - } - - void *mem = alloc->buf + alloc->offset; - alloc->offset += sz; - - return mem; -} - -void frame_allocator_clear(struct frame_allocator *alloc) { alloc->offset = 0; } |
