Skip to content

Commit 9ebc037

Browse files
committed
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.
1 parent 88a8043 commit 9ebc037

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

py/malloc.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ void *m_realloc(void *ptr, size_t new_num_bytes) {
147147
MP_STATE_MEM(current_bytes_allocated) += diff;
148148
UPDATE_PEAK();
149149
#endif
150+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
150151
DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
152+
#else
153+
DEBUG_printf("realloc %p, %d : %p\n", ptr, new_num_bytes, new_ptr);
154+
#endif
151155
return new_ptr;
152156
}
153157

@@ -171,7 +175,11 @@ void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move) {
171175
UPDATE_PEAK();
172176
}
173177
#endif
178+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
174179
DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
180+
#else
181+
DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, new_num_bytes, new_ptr);
182+
#endif
175183
return new_ptr;
176184
}
177185

@@ -184,7 +192,11 @@ void m_free(void *ptr) {
184192
#if MICROPY_MEM_STATS
185193
MP_STATE_MEM(current_bytes_allocated) -= num_bytes;
186194
#endif
195+
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
187196
DEBUG_printf("free %p, %d\n", ptr, num_bytes);
197+
#else
198+
DEBUG_printf("free %p\n", ptr);
199+
#endif
188200
}
189201

190202
#if MICROPY_MEM_STATS

0 commit comments

Comments
 (0)