aboutsummaryrefslogtreecommitdiff
path: root/mem
diff options
context:
space:
mode:
Diffstat (limited to 'mem')
-rw-r--r--mem/src/mem.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/mem/src/mem.c b/mem/src/mem.c
index 4f5e5ef..c2af518 100644
--- a/mem/src/mem.c
+++ b/mem/src/mem.c
@@ -46,11 +46,11 @@ void mem_del_(Memory* mem) {
46 if (mem->dynamic) { 46 if (mem->dynamic) {
47 if (mem->chunks) { 47 if (mem->chunks) {
48 free(mem->chunks); 48 free(mem->chunks);
49 mem->chunks = 0; 49 mem->chunks = nullptr;
50 } 50 }
51 if (mem->blocks) { 51 if (mem->blocks) {
52 free(mem->blocks); 52 free(mem->blocks);
53 mem->blocks = 0; 53 mem->blocks = nullptr;
54 } 54 }
55 } 55 }
56} 56}
@@ -113,10 +113,11 @@ void* mem_alloc_(Memory* mem, size_t num_blocks) {
113 return &mem->blocks[chunk_idx * mem->block_size_bytes]; 113 return &mem->blocks[chunk_idx * mem->block_size_bytes];
114 } else { 114 } else {
115 if (mem->trap) { 115 if (mem->trap) {
116 FAIL("Memory allocation failed, increase the allocator's capacity or " 116 FAIL(
117 "avoid fragmentation."); 117 "Memory allocation failed, increase the allocator's capacity or "
118 "avoid fragmentation.");
118 } 119 }
119 return 0; // Large-enough free chunk not found. 120 return nullptr; // Large-enough free chunk not found.
120 } 121 }
121} 122}
122 123
@@ -172,7 +173,7 @@ void mem_free_(Memory* mem, void** chunk_ptr) {
172 173
173 mem->num_used_blocks--; 174 mem->num_used_blocks--;
174 175
175 *chunk_ptr = 0; 176 *chunk_ptr = nullptr;
176} 177}
177 178
178// The handle is the chunk's index. We don't call it an index in the public API 179// The handle is the chunk's index. We don't call it an index in the public API