std_allocator and testing

This commit is contained in:
2025-10-03 20:21:27 +02:00
parent fb129ac32f
commit 5fed6d24d8
4 changed files with 71 additions and 24 deletions
+32
View File
@@ -0,0 +1,32 @@
#include "allocator.h"
static void *stdlib_alloc(void *this, size_t bytes, const char *file, int line) {
(void)this;
(void)file;
(void)line;
return malloc(bytes);
}
static void *stdlib_resize(void *this, void *old_ptr, size_t bytes, const char *file, int line) {
(void)this;
(void)file;
(void)line;
return realloc(old_ptr, bytes);
}
static void stdlib_free(void *this, void *ptr, const char *file, int line) {
(void)this;
(void)file;
(void)line;
free(ptr);
}
static const allocator_vtbl_t stdlib_vtbl = {
.alloc = stdlib_alloc,
.resize = stdlib_resize,
.free = stdlib_free,
};
const allocator_t allocator_stdlib = (allocator_t) {
.this=NULL,
.vtbl=&stdlib_vtbl,
};