diff options
| author | 3gg <3gg@shellblade.net> | 2025-06-30 15:29:44 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-06-30 15:29:44 -0700 |
| commit | 25a367862dbdfb0fdfdfc6f619af3f0a7e0fe79f (patch) | |
| tree | 60269cf9a704c059495f52c3ad5a23794b2698c3 /mem/src | |
| parent | 9b3ba8c80360c09dd32ee9645c536161b5dd0cff (diff) | |
Use nullptr
Diffstat (limited to 'mem/src')
| -rw-r--r-- | mem/src/mem.c | 13 |
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 |
