aboutsummaryrefslogtreecommitdiffstats
path: root/src/alloc.c
diff options
context:
space:
mode:
authorDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-02 18:29:20 -0500
committerDouglas B. Rumbaugh <doug@douglasrumbaugh.com>2025-11-02 18:29:20 -0500
commit11521b99661f969ba7adad9d2366108a1a001ab0 (patch)
tree5a8d1225cfd9a4b58a5277d6d7f1f5112a7cf020 /src/alloc.c
parentf88198cb987ab006f3406698fec410ff1de05534 (diff)
downloadliballoc-11521b99661f969ba7adad9d2366108a1a001ab0.tar.gz
Defined allocator behavior for 0 byte requests
Diffstat (limited to 'src/alloc.c')
-rw-r--r--src/alloc.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 39cbf88..32eb18a 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -44,6 +44,11 @@ void *allocate(size_t size) {
initialize();
}
+ /* special case for a size 0 allocation */
+ if (size == 0) {
+ return NULL;
+ }
+
/*
* pad the requested size to ensure alignment using
* the alignment one-liner we discussed in class