[PATCH 05/40] spl: alloc: call full alloc functions if malloc pool is available

Sughosh Ganu sughosh.ganu at linaro.org
Wed Jul 24 08:01:49 CEST 2024


If the malloc simple functionality is enabled in SPL, it is not
possible to call the full-implementation alloc functions even after
the heap is set-up in ram memory. Check for this condition and
call the functions when enabled.

Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
Changes since rfc: New patch

 common/malloc_simple.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/common/malloc_simple.c b/common/malloc_simple.c
index 4e6d7952b3..982287defe 100644
--- a/common/malloc_simple.c
+++ b/common/malloc_simple.c
@@ -40,6 +40,10 @@ void *malloc_simple(size_t bytes)
 {
 	void *ptr;
 
+#if IS_ENABLED(CONFIG_SPL_SYS_MALLOC) && IS_ENABLED(CONFIG_SPL_LMB)
+	if (gd->flags & GD_FLG_FULL_MALLOC_INIT)
+		return mALLOc(bytes);
+#endif
 	ptr = alloc_simple(bytes, 1);
 	if (!ptr)
 		return ptr;
@@ -50,6 +54,15 @@ void *malloc_simple(size_t bytes)
 	return ptr;
 }
 
+void *realloc_simple(void *oldmem, size_t bytes)
+{
+#if IS_ENABLED(CONFIG_SPL_SYS_MALLOC) && IS_ENABLED(CONFIG_SPL_LMB)
+	if (gd->flags & GD_FLG_FULL_MALLOC_INIT)
+		return rEALLOc(oldmem, bytes);
+#endif
+	return NULL;
+}
+
 void *memalign_simple(size_t align, size_t bytes)
 {
 	void *ptr;
-- 
2.34.1



More information about the U-Boot mailing list