13#ifndef __clang_analyzer__
14#error "The allocator being debugged must be defined"
17#define ALLOC nullalloc
26 return (
SELF){.name =
name, .base = alloc};
33 printf(
"%s allocated %zu bytes at %p\n", self->name,
size, ptr);
35 printf(
"%s failed to allocate %zu bytes\n", self->name,
size);
44 printf(
"%s allocated %zu bytes at %p\n", self->name, count *
size, ptr);
46 printf(
"%s failed to allocate %zu bytes\n", self->name, count *
size);
55 printf(
"%s reallocated memory at %p to %zu bytes\n", self->name, new_ptr,
size);
57 printf(
"%s failed to reallocate memory at %p to %zu bytes\n", self->name, ptr,
size);
64 printf(
"%s freeing memory at %p\n", self->name, ptr);
#define ALLOC
An allocator that prints to stdout when it allocates or frees memory.
static void free(SELF *self, void *ptr)
static void * realloc(SELF *self, void *ptr, size_t size)
static void * malloc(SELF *self, size_t size)
static void * calloc(SELF *self, size_t count, size_t size)
#define DEBUG_ASSERT(expr)
static INDEX_TYPE size(SELF const *self)
#define ALLOC
A simple vector.