diff options
| author | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 18:29:20 -0500 |
|---|---|---|
| committer | Douglas B. Rumbaugh <doug@douglasrumbaugh.com> | 2025-11-02 18:29:20 -0500 |
| commit | 11521b99661f969ba7adad9d2366108a1a001ab0 (patch) | |
| tree | 5a8d1225cfd9a4b58a5277d6d7f1f5112a7cf020 /src | |
| parent | f88198cb987ab006f3406698fec410ff1de05534 (diff) | |
| download | liballoc-11521b99661f969ba7adad9d2366108a1a001ab0.tar.gz | |
Defined allocator behavior for 0 byte requests
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 5 |
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 |