diff options
author | H. Peter Anvin <hpa@zytor.com> | 2001-10-23 06:01:43 +0000 |
---|---|---|
committer | H. Peter Anvin <hpa@zytor.com> | 2001-10-23 06:01:43 +0000 |
commit | fbb530110cb5127532ed6ff1081f84abf574c43d (patch) | |
tree | fd8ab0a521e7b90729f9e2b28e9bdd796d32e219 /malloc.c | |
parent | d15e7744e7ab4cb7fa0ebdd8e8d652674dd95afa (diff) | |
download | lpsm-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 */ } |