diff options
Diffstat (limited to 'py/gc.c')
-rw-r--r-- | py/gc.c | 7 |
1 files changed, 6 insertions, 1 deletions
@@ -522,7 +522,7 @@ void *gc_realloc(void *ptr, mp_uint_t n_bytes) { #else // Alternative gc_realloc impl -void *gc_realloc(void *ptr_in, mp_uint_t n_bytes) { +void *gc_realloc(void *ptr_in, mp_uint_t n_bytes, bool allow_move) { if (MP_STATE_MEM(gc_lock_depth) > 0) { return NULL; } @@ -624,6 +624,11 @@ void *gc_realloc(void *ptr_in, mp_uint_t n_bytes) { return ptr_in; } + if (!allow_move) { + // not allowed to move memory block so return failure + return NULL; + } + // can't resize inplace; try to find a new contiguous chain void *ptr_out = gc_alloc(n_bytes, #if MICROPY_ENABLE_FINALISER |