diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 15:41:54 -0500 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 15:41:54 -0500 |
| commit | a66d9582a16eb3c15bf727db84431660ae20b2f2 (patch) | |
| tree | d820145d063adfcec8f7ce8028518f1ec8d0bad6 /src/alloc.c | |
| parent | cadb32d38b840b16804c8d3370408c7db7a32a2d (diff) | |
| download | liballoc-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/alloc.c')
| -rw-r--r-- | src/alloc.c | 4 |
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); } |