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.
This commit is contained in:
+9
-16
@@ -30,32 +30,25 @@ void buffer_allocator_reset(buffer_allocator_t *this) {
|
||||
this->size = 0;
|
||||
}
|
||||
|
||||
static void *buffer_alloc(void *this, size_t bytes, const char *file, int line) {
|
||||
(void)file;
|
||||
(void)line;
|
||||
static void *buffer_alloc_impl(void *this, size_t bytes) {
|
||||
return buffer_allocator_alloc((buffer_allocator_t *)this, bytes);
|
||||
}
|
||||
|
||||
static void *buffer_resize(void *this, void *old_ptr, size_t bytes, const char *file, int line) {
|
||||
(void)file;
|
||||
(void)line;
|
||||
return buffer_allocator_resize(this, old_ptr, bytes);
|
||||
static void *buffer_resize_impl(void *this, void *old_ptr, size_t bytes) {
|
||||
return buffer_allocator_resize((buffer_allocator_t *)this, old_ptr, bytes);
|
||||
}
|
||||
|
||||
static void buffer_free(void *this, void *ptr, const char *file, int line) {
|
||||
(void)this;
|
||||
(void)ptr;
|
||||
(void)file;
|
||||
(void)line;
|
||||
static void buffer_reset_impl(void *this) {
|
||||
buffer_allocator_reset((buffer_allocator_t *)this);
|
||||
}
|
||||
|
||||
static const allocator_vtbl_t buffer_vtbl = {
|
||||
.alloc = buffer_alloc,
|
||||
.resize = buffer_resize,
|
||||
.free = buffer_free,
|
||||
.alloc = buffer_alloc_impl,
|
||||
.resize = buffer_resize_impl,
|
||||
.reset = buffer_reset_impl,
|
||||
};
|
||||
|
||||
allocator_t buffer_allocator_interface(buffer_allocator_t *this) {
|
||||
allocator_t buffer_allocator(buffer_allocator_t *this) {
|
||||
return (allocator_t) {
|
||||
.this=this,
|
||||
.vtbl=&buffer_vtbl,
|
||||
|
||||
Reference in New Issue
Block a user