aboutsummaryrefslogtreecommitdiffstats
path: root/malloc.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 /malloc.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 'malloc.c')
-rw-r--r--malloc.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/malloc.c b/malloc.c
index e2ae112..d565ebc 100644
--- a/malloc.c
+++ b/malloc.c
@@ -22,6 +22,7 @@
#include <inttypes.h>
#include <limits.h>
#include <string.h>
+#include <errno.h>
#include "lpsm.h"
#include "internals.h"
@@ -190,8 +191,10 @@ void *lpsm_malloc_buddy(size_t size)
order++;
xbit = lpsm_malloc_buddy_xbit(order);
- if ( !xbit )
+ if ( !xbit ) {
+ errno = ENOMEM;
return NULL;
+ }
obit = 1 << (AH->arena_size_lg2 - order);
@@ -268,6 +271,7 @@ void *lpsm_malloc_slab(size_t size)
if ( !sh ) {
/* Empty free list, need a new page */
if ( !(sh = lpsm_make_new_slab(si,index)) )
+ errno = ENOMEM;
return NULL; /* Unavailable to allocate new slab */
}