Origin: https://git.kernel.org/pub/scm/libs/klibc/klibc.git/commit/?id=
7f6626d12daa2f1efd9953d1f4ba2065348dc5cd
malloc() is specified to set errno = ENOMEM on failure, so do that.
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Gbp-Pq: Name 0035-klibc-malloc-Set-errno-on-failure.patch
#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
#endif
if (fp == (struct free_arena_header *)MAP_FAILED) {
+ errno = ENOMEM;
return NULL; /* Failed to get a block */
}