stdlib: set errno=ENOMEM after failed malloc()

This commit is contained in:
Lephenixnoir 2022-01-01 17:09:48 +01:00
parent f7b85f18bd
commit 3046304497
No known key found for this signature in database
GPG key ID: 1BBA026E13FC0495

View file

@ -1,8 +1,12 @@
#include <stdlib.h>
#include <errno.h>
extern void *kmalloc(size_t size, char const *arena_name);
void *malloc(size_t size)
{
return kmalloc(size, NULL);
void *ptr = kmalloc(size, NULL);
if(ptr == NULL)
errno = ENOMEM;
return ptr;
}