[Concept,14/37] malloc: Reduce code size with INSECURE and NO_MALLINFO

Message ID 20251201170529.3237986-15-sjg@u-boot.org
State New
Headers
Series malloc: Import dlmalloc 2.8.6 |

Commit Message

Simon Glass Dec. 1, 2025, 5:04 p.m. UTC
  From: Simon Glass <simon.glass@canonical.com>

Enable INSECURE=1 to skip runtime heap validation checks (except for
sandbox), and NO_MALLINFO=1 to remove mallinfo support (except when unit
tests are enabled). These reduce code size significantly.

Co-developed-by: Claude <noreply@anthropic.com>
Signed-off-by: Simon Glass <simon.glass@canonical.com>
---

 common/dlmalloc.c | 8 ++++++++
 1 file changed, 8 insertions(+)
  

Patch

diff --git a/common/dlmalloc.c b/common/dlmalloc.c
index 98de6523758..268d3fea52a 100644
--- a/common/dlmalloc.c
+++ b/common/dlmalloc.c
@@ -563,6 +563,14 @@  MAX_RELEASE_CHECK_RATE   default: 4095 unless not HAVE_MMAP
 #define NO_MALLOC_STATS 1
 #define USE_LOCKS 0
 #define USE_SPIN_LOCKS 0
+
+#if !CONFIG_IS_ENABLED(UNIT_TEST)
+#define NO_MALLINFO 1
+#endif
+#if !CONFIG_IS_ENABLED(SANDBOX)
+#define INSECURE 1
+#endif
+
 #define MALLOC_FAILURE_ACTION
 #define ABORT do {} while (1)