[klibc] malloc: Set errno on failure
malloc() is specified to set errno = ENOMEM on failure, so do that.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
diff --git a/usr/klibc/malloc.c b/usr/klibc/malloc.c
index 413b733..bb57c9f 100644
--- a/usr/klibc/malloc.c
+++ b/usr/klibc/malloc.c
@@ -8,6 +8,7 @@
#include <unistd.h>
#include <sys/mman.h>
#include <assert.h>
+#include <errno.h>
#include "malloc.h"
/* Both the arena list and the free memory list are double linked
@@ -169,6 +170,7 @@
#endif
if (fp == (struct free_arena_header *)MAP_FAILED) {
+ errno = ENOMEM;
return NULL; /* Failed to get a block */
}