aboutsummaryrefslogtreecommitdiffstats
path: root/zalloc.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 /zalloc.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 'zalloc.c')
-rw-r--r--zalloc.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/zalloc.c b/zalloc.c
index b6e5195..f972b16 100644
--- a/zalloc.c
+++ b/zalloc.c
@@ -22,6 +22,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <errno.h>
#include <sys/mman.h>
#include "lpsm.h"
#include "internals.h"
@@ -38,7 +39,8 @@ void *lpsm_zalloc(size_t size)
xbit = lpsm_malloc_buddy_xbit(size);
if ( !xbit ) {
- ptr = NULL;
+ errno = ENOMEM;
+ return NULL;
} else {
rorder = AH->arena_size_lg2 - order;
obit = 1 << rorder;