From ffdc7343f4d967d9be1429644102a044af5e0556 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Thu, 7 Jun 2018 23:55:59 -0400 Subject: [PATCH] Import placeholders for free() and malloc() --- include/errno.h | 1 + include/stdlib.h | 2 ++ src/lib/stdlib.c | 17 +++++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/include/errno.h b/include/errno.h index ef75d2c..879ec7c 100644 --- a/include/errno.h +++ b/include/errno.h @@ -10,6 +10,7 @@ /* constants */ # define EBADF 9 +# define ENOMEM 12 # define ENODEV 19 # define EINVAL 22 # define ERANGE 34 diff --git a/include/stdlib.h b/include/stdlib.h index e6c88f9..b1830ed 100644 --- a/include/stdlib.h +++ b/include/stdlib.h @@ -16,7 +16,9 @@ void abort(void); int abs(int x); uint32_t arc4random(void); void exit(int status); +void free(void * ptr); long labs(long x); long long llabs(long long x); +void * malloc(size_t size); #endif /* !UKERNEL_STDLIB_H */ diff --git a/src/lib/stdlib.c b/src/lib/stdlib.c index a319af8..e5c0efd 100644 --- a/src/lib/stdlib.c +++ b/src/lib/stdlib.c @@ -5,6 +5,7 @@ #include +#include #include @@ -39,6 +40,12 @@ void exit(int status) } +/* free */ +void free(void * ptr) +{ +} + + /* labs */ long labs(long x) { @@ -51,3 +58,13 @@ long long llabs(long long x) { return (x >= 0) ? x : -x; } + + +/* malloc */ +void * malloc(size_t size) +{ + if(size == 0) + return NULL; + errno = ENOMEM; + return NULL; +}