[PATCH] fixup! malloc: implement malloc_usable_size()
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Aug 6 05:56:58 PDT 2024
- Prevent sandbox from using libc function inadvertently
- Implement wrapper for libc malloc
- Implement for dummy_malloc
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
arch/sandbox/Makefile | 1 +
arch/sandbox/os/libc_malloc.c | 5 +++++
common/dummy_malloc.c | 5 +++++
3 files changed, 11 insertions(+)
diff --git a/arch/sandbox/Makefile b/arch/sandbox/Makefile
index d5327d44e097..5c51f2de38b3 100644
--- a/arch/sandbox/Makefile
+++ b/arch/sandbox/Makefile
@@ -23,6 +23,7 @@ lds-y := $(BOARD)/barebox.lds
TEXT_BASE = $(CONFIG_TEXT_BASE)
KBUILD_CFLAGS += -Dmalloc=barebox_malloc -Dcalloc=barebox_calloc \
-Dmalloc_stats=barebox_malloc_stats -Dmemalign=barebox_memalign \
+ -Dmalloc_usable_size=barebox_malloc_usable_size \
-Dfree=barebox_free -Drealloc=barebox_realloc \
-Dread=barebox_read -Dwrite=barebox_write \
-Dopen=barebox_open -Dclose=barebox_close \
diff --git a/arch/sandbox/os/libc_malloc.c b/arch/sandbox/os/libc_malloc.c
index 975c41b0ec49..e34156cd49e7 100644
--- a/arch/sandbox/os/libc_malloc.c
+++ b/arch/sandbox/os/libc_malloc.c
@@ -32,6 +32,11 @@ void *barebox_malloc(size_t size)
return mem;
}
+size_t barebox_malloc_usable_size(void *mem)
+{
+ return malloc_usable_size(mem);
+}
+
void barebox_free(void *ptr)
{
free(ptr);
diff --git a/common/dummy_malloc.c b/common/dummy_malloc.c
index 7a96afec76e0..140ba314272a 100644
--- a/common/dummy_malloc.c
+++ b/common/dummy_malloc.c
@@ -30,6 +30,11 @@ void free(void *ptr)
{
}
+size_t malloc_usable_size(void *mem)
+{
+ BUG();
+}
+
void *realloc(void *ptr, size_t size)
{
BUG();
--
2.39.2
More information about the barebox
mailing list