Go to the source code of this file.
|
| struct | SELF |
| | An allocator that prints to stdout when it allocates or frees memory. More...
|
◆ calloc()
| void * calloc |
( |
SELF * | self, |
|
|
size_t | count, |
|
|
size_t | size ) |
|
static |
Definition at line 34 of file template.h.
34 {
37 if (ptr) {
38 printf(
"%s allocated %zu bytes at %p\n", self->
name, count *
size, ptr);
39 } else {
40 printf(
"%s failed to allocate %zu bytes\n", self->
name, count *
size);
41 }
42 return ptr;
43}
static void * calloc(SELF *self, size_t count, size_t size)
static INDEX_TYPE size(SELF const *self)
#define DC_ASSUME(expr,...)
◆ DC_TRAIT_ALLOC()
◆ debug()
Definition at line 62 of file template.h.
62 {
69}
dc_debug_fmt dc_debug_fmt_scope_end(dc_debug_fmt fmt)
dc_debug_fmt dc_debug_fmt_scope_begin(dc_debug_fmt fmt)
static void dc_debug_fmt_print(dc_debug_fmt fmt, FILE *stream, const char *format,...)
static FILE * stream(SELF *self)
Opens a file for.
◆ free()
| void free |
( |
SELF * | self, |
|
|
void * | ptr ) |
|
static |
◆ malloc()
| void * malloc |
( |
SELF * | self, |
|
|
size_t | size ) |
|
static |
- Examples
- container/arena/basic.c.
Definition at line 23 of file template.h.
23 {
26 if (ptr) {
27 printf(
"%s allocated %zu bytes at %p\n", self->
name,
size, ptr);
28 } else {
29 printf(
"%s failed to allocate %zu bytes\n", self->
name,
size);
30 }
31 return ptr;
32}
static void * malloc(SELF *self, size_t size)
◆ new()
| SELF new |
( |
char const * | name, |
|
|
ALLOC * | alloc ) |
|
static |
◆ realloc()
| void * realloc |
( |
SELF * | self, |
|
|
void * | ptr, |
|
|
size_t | size ) |
|
static |
Definition at line 45 of file template.h.
45 {
48 if (new_ptr) {
49 printf(
"%s reallocated memory at %p to %zu bytes\n", self->
name, new_ptr,
size);
50 } else {
51 printf(
"%s failed to reallocate memory at %p to %zu bytes\n", self->
name, ptr,
size);
52 }
53 return new_ptr;
54}
static void * realloc(SELF *self, void *ptr, size_t size)