aboutsummaryrefslogtreecommitdiffstats
path: root/free.c
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2001-10-23 06:01:43 +0000
committerH. Peter Anvin <hpa@zytor.com>2001-10-23 06:01:43 +0000
commitfbb530110cb5127532ed6ff1081f84abf574c43d (patch)
treefd8ab0a521e7b90729f9e2b28e9bdd796d32e219 /free.c
parentd15e7744e7ab4cb7fa0ebdd8e8d652674dd95afa (diff)
downloadlpsm-fbb530110cb5127532ed6ff1081f84abf574c43d.tar.gz
lpsm-fbb530110cb5127532ed6ff1081f84abf574c43d.tar.xz
lpsm-fbb530110cb5127532ed6ff1081f84abf574c43d.zip
Be a bit more correct: set errno to ENOMEM if we fail to allocate
memory.
Diffstat (limited to 'free.c')
-rw-r--r--free.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/free.c b/free.c
index 627e53f..f38f1db 100644
--- a/free.c
+++ b/free.c
@@ -148,8 +148,10 @@ void lpsm_free_slab(void *ptr)
void lpsm_free(void *ptr)
{
/* Buddy allocations are ALWAYS page-aligned, SLAB allocations never */
- if ( (uintptr_t)ptr & (BUDDY_SIZE_MIN-1) )
- lpsm_free_slab(ptr);
- else
- lpsm_free_buddy(ptr);
+ if ( ptr ) {
+ if ( (uintptr_t)ptr & (BUDDY_SIZE_MIN-1) )
+ lpsm_free_slab(ptr);
+ else
+ lpsm_free_buddy(ptr);
+ }
}