Files
cig/std_allocator.c
T
roodletoof 01b8150625 refactor
remove the free function entirely. all allocators are now expected to
implement reset instead. I reallized I never ever want to free an
individual allocation ever again. The forever_allocator is a special
case wherEreset is a no-op. The arena allocator was deleted. It will be
replaced soon.
2025-12-02 20:21:12 +01:00

28 lines
558 B
C

#include "cig.h"
static void *forever_alloc(void *this, size_t bytes) {
(void)this;
return malloc(bytes);
}
static void *forever_resize(void *this, void *old_ptr, size_t bytes) {
(void)this;
return realloc(old_ptr, bytes);
}
static void forever_no_op(void *this) {
(void)this;
}
static const allocator_vtbl_t forever_vtbl = {
.alloc = forever_alloc,
.resize = forever_resize,
.reset = forever_no_op,
};
allocator_t forever_allocator() {
return (allocator_t) {
.this=NULL,
.vtbl=&forever_vtbl,
};
}