aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-02 15:41:54 -0500
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-02 15:41:54 -0500
commita66d9582a16eb3c15bf727db84431660ae20b2f2 (patch)
treed820145d063adfcec8f7ce8028518f1ec8d0bad6 /src
parentcadb32d38b840b16804c8d3370408c7db7a32a2d (diff)
downloadliballoc-a66d9582a16eb3c15bf727db84431660ae20b2f2.tar.gz
alloc.c: releasing NULL now works
My initial free list implementation revealed a bug that I wasn't handling release(NULL) correctly, resulting in a segfault. After this commit, all existing tests pass for liballoc.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 830e49f..2f4aa03 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -76,6 +76,10 @@ void *allocate(size_t size) {
}
void release(void *ptr) {
+ if (!ptr) {
+ return;
+ }
+
fl_add_node(&free_list, ptr);
fl_coalesce_nodes(free_list);
}