Go to the source code of this file.
|
| | DC_ZERO_SIZED (stdalloc) |
| | An allocator for the standard allocator, which only has global state,.
|
| | DC_TRAIT_REFERENCABLE_SINGLETON (stdalloc, stdalloc_instance) |
| static DC_PUBLIC void * | allocate_uninit (stdalloc_ref, size_t size) |
| static DC_PUBLIC void * | allocate_zeroed (stdalloc_ref, size_t size) |
| static DC_PUBLIC void * | reallocate (stdalloc_ref, void *ptr, size_t old_size, size_t new_size) |
| static DC_PUBLIC void | deallocate (stdalloc_ref, void *ptr, size_t size) |
| static DC_PUBLIC void | debug (stdalloc const *self, dc_debug_fmt fmt, FILE *stream) |
| static DC_PUBLIC void | delete (stdalloc *self) |
| | DC_TRAIT_ALLOC (stdalloc) |
◆ allocate_uninit()
| DC_PUBLIC void * allocate_uninit |
( |
stdalloc_ref | , |
|
|
size_t | size ) |
|
static |
Definition at line 17 of file std.h.
17 {
19 void* alloc = malloc(
size);
20
21
22
24 DC_ASSERT(alloc != NULL,
"Standard allocator failed to malloc");
25 return alloc;
26}
static DC_PUBLIC size_t size(SELF const *self)
static DC_PUBLIC void dc_memory_tracker_set(dc_memory_tracker_level level, dc_memory_tracker_capability cap, const volatile void *addr, size_t size)
@ DC_MEMORY_TRACKER_LVL_ALLOC
@ DC_MEMORY_TRACKER_CAP_WRITE
#define DC_ASSERT(expr,...)
◆ allocate_zeroed()
| DC_PUBLIC void * allocate_zeroed |
( |
stdalloc_ref | , |
|
|
size_t | size ) |
|
static |
Definition at line 28 of file std.h.
28 {
30 void* alloc = calloc(
size, 1);
31
32
33
36
37 DC_ASSERT(alloc != NULL,
"Standard allocator failed to calloc");
38 return alloc;
39}
@ DC_MEMORY_TRACKER_CAP_READ_WRITE
◆ DC_TRAIT_ALLOC()
| DC_TRAIT_ALLOC |
( |
stdalloc | | ) |
|
◆ DC_TRAIT_REFERENCABLE_SINGLETON()
◆ DC_ZERO_SIZED()
| DC_ZERO_SIZED |
( |
stdalloc | | ) |
|
An allocator for the standard allocator, which only has global state,.
◆ deallocate()
| DC_PUBLIC void deallocate |
( |
stdalloc_ref | , |
|
|
void * | ptr, |
|
|
size_t | size ) |
|
static |
Definition at line 68 of file std.h.
68 {
70
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89 free(ptr);
90}
#define DC_ASSUME(expr,...)
◆ debug()
Definition at line 92 of file std.h.
92 {
94 (void)fmt;
95 fprintf(
stream,
"stdalloc@%p { }", (
void*)self);
96}
static DC_PUBLIC FILE * stream(SELF *self)
◆ delete()
Definition at line 98 of file std.h.
◆ reallocate()
| DC_PUBLIC void * reallocate |
( |
stdalloc_ref | , |
|
|
void * | ptr, |
|
|
size_t | old_size, |
|
|
size_t | new_size ) |
|
static |
Definition at line 41 of file std.h.
42 {
43 DC_ASSERT(new_size > 0,
"Cannot allocate zero sized");
44 DC_ASSERT(ptr,
"Cannot reallocate a null pointer");
45 DC_ASSUME(old_size > 0,
"Could never have allocated zero sized");
46
47 if (new_size < old_size) {
48
49
50
51
52
54 (char const*)ptr + new_size, old_size - new_size);
55 }
56
57 void* new_ptr = realloc(ptr, new_size);
58 DC_ASSERT(new_ptr != NULL,
"Standard allocator failed to realloc");
59
60 if (new_size > old_size) {
62 (char*)new_ptr + old_size, new_size - old_size);
63 }
64
65 return new_ptr;
66}
◆ stdalloc_instance
| stdalloc stdalloc_instance = {} |
|
static |
Definition at line 14 of file std.h.