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 36 of file template.h.
36 {
39 if (ptr) {
40 printf(
"%s allocated %zu bytes at %p\n", self->
name, count *
size, ptr);
41 } else {
42 printf(
"%s failed to allocate %zu bytes\n", self->
name, count *
size);
43 }
44 return ptr;
45}
static void * calloc(SELF *self, size_t count, size_t size)
static INDEX_TYPE size(SELF const *self)
◆ 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 25 of file template.h.
25 {
28 if (ptr) {
29 printf(
"%s allocated %zu bytes at %p\n", self->
name,
size, ptr);
30 } else {
31 printf(
"%s failed to allocate %zu bytes\n", self->
name,
size);
32 }
33 return ptr;
34}
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 47 of file template.h.
47 {
50 if (new_ptr) {
51 printf(
"%s reallocated memory at %p to %zu bytes\n", self->
name, new_ptr,
size);
52 } else {
53 printf(
"%s failed to reallocate memory at %p to %zu bytes\n", self->
name, ptr,
size);
54 }
55 return new_ptr;
56}
static void * realloc(SELF *self, void *ptr, size_t size)
◆ TRAIT_ALLOC()