From 9ebc037eee575fd951dea92c82ed9704d9101924 Mon Sep 17 00:00:00 2001
From: Paul Sokolovsky <pfalcon@users.sourceforge.net>
Date: Thu, 7 Dec 2017 17:57:33 +0200
Subject: [PATCH] py/malloc: Allow to use debug logging if
 !MICROPY_MALLOC_USES_ALLOCATED_SIZE.

This is mostly a workaround for forceful rebuilding of mpy-cross on every
codebase change. If this file has debug logging enabled (by patching),
mpy-cross build failed.
---
 py/malloc.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/py/malloc.c b/py/malloc.c
index 818a3e57a..6835ed7c9 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -147,7 +147,11 @@ void *m_realloc(void *ptr, size_t new_num_bytes) {
     MP_STATE_MEM(current_bytes_allocated) += diff;
     UPDATE_PEAK();
 #endif
+    #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
     DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
+    #else
+    DEBUG_printf("realloc %p, %d : %p\n", ptr, new_num_bytes, new_ptr);
+    #endif
     return new_ptr;
 }
 
@@ -171,7 +175,11 @@ void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move) {
         UPDATE_PEAK();
     }
 #endif
+    #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
     DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
+    #else
+    DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, new_num_bytes, new_ptr);
+    #endif
     return new_ptr;
 }
 
@@ -184,7 +192,11 @@ void m_free(void *ptr) {
 #if MICROPY_MEM_STATS
     MP_STATE_MEM(current_bytes_allocated) -= num_bytes;
 #endif
+    #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
     DEBUG_printf("free %p, %d\n", ptr, num_bytes);
+    #else
+    DEBUG_printf("free %p\n", ptr);
+    #endif
 }
 
 #if MICROPY_MEM_STATS
-- 
GitLab