Go to the source code of this file.
|
| struct | SELF |
| | An allocator that prints to stdout when it allocates or frees memory. More...
|
|
| static DC_PUBLIC SELF | new (char const *name, FILE *stream, ref alloc_ref) |
| static DC_PUBLIC void * | allocate_uninit (SELF *self, size_t size) |
| static DC_PUBLIC void * | allocate_zeroed (SELF *self, size_t size) |
| static DC_PUBLIC void * | reallocate (SELF *self, void *ptr, size_t old_size, size_t new_size) |
| static DC_PUBLIC void | deallocate (SELF *self, void *ptr, size_t size) |
| static DC_PUBLIC void | debug (SELF const *self, dc_debug_fmt fmt, FILE *stream) |
| static DC_PUBLIC void | delete (SELF *self) |
| | DC_TRAIT_REFERENCABLE_BY_PTR (SELF) |
| | DC_TRAIT_ALLOC (SELF) |
◆ allocate_uninit()
Definition at line 30 of file template.h.
30 {
33 fprintf(self->
stream,
"[%s] %s(size=%zu) -> %p\n", self->
name, __func__,
size, ptr);
34 return ptr;
35}
static DC_PUBLIC void * allocate_uninit(SELF *self, size_t size)
static DC_PUBLIC size_t size(SELF const *self)
#define DC_ASSUME(expr,...)
◆ allocate_zeroed()
Definition at line 37 of file template.h.
37 {
40 fprintf(self->
stream,
"[%s] %s(size=%zu) -> %p\n", self->
name, __func__,
size, ptr);
41 return ptr;
42}
static DC_PUBLIC void * allocate_zeroed(SELF *self, size_t size)
◆ DC_TRAIT_ALLOC()
◆ DC_TRAIT_REFERENCABLE_BY_PTR()
| DC_TRAIT_REFERENCABLE_BY_PTR |
( |
SELF | | ) |
|
◆ deallocate()
| DC_PUBLIC void deallocate |
( |
SELF * | self, |
|
|
void * | ptr, |
|
|
size_t | size ) |
|
static |
Definition at line 53 of file template.h.
53 {
55 fprintf(self->
stream,
"[%s] %s(ptr=%p, size=%zu)\n", self->
name, __func__, ptr,
size);
57}
static DC_PUBLIC void deallocate(SELF *self, void *ptr, size_t size)
◆ debug()
Definition at line 59 of file template.h.
59 {
68}
static DC_PUBLIC void debug(SELF const *self, dc_debug_fmt fmt, FILE *stream)
static DC_PUBLIC void dc_debug_fmt_print(dc_debug_fmt fmt, FILE *stream, const char *format,...)
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_scope_end(dc_debug_fmt fmt)
static DC_PUBLIC dc_debug_fmt dc_debug_fmt_scope_begin(dc_debug_fmt fmt)
#define DC_EXPAND_STRING(NAME)
static DC_PUBLIC FILE * stream(SELF *self)
◆ delete()
Definition at line 70 of file template.h.
70 {
72 fprintf(self->
stream,
"[%s]: %s\n", self->
name, __func__);
73}
◆ new()
| DC_PUBLIC SELF new |
( |
char const * | name, |
|
|
FILE * | stream, |
|
|
ref | alloc_ref ) |
|
static |
Definition at line 20 of file template.h.
20 {
22 (
void*)
NS(
NS(
ALLOC, ref), deref)(alloc_ref));
26 .alloc_ref = alloc_ref,
27 };
28}
◆ reallocate()
| DC_PUBLIC void * reallocate |
( |
SELF * | self, |
|
|
void * | ptr, |
|
|
size_t | old_size, |
|
|
size_t | new_size ) |
|
static |
Definition at line 44 of file template.h.
45 {
48 fprintf(self->
stream,
"[%s] %s(ptr=%p, old_size=%zu, new_size=%zu) -> %p\n", self->
name,
49 __func__, ptr, old_size, new_size, new_ptr);
50 return new_ptr;
51}
static DC_PUBLIC void * reallocate(SELF *self, void *ptr, size_t old_size, size_t new_size)