summaryrefslogtreecommitdiffstatshomepage
path: root/py/gc.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/gc.c')
-rw-r--r--py/gc.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/py/gc.c b/py/gc.c
index 6cdafc03b1..7283e5f1f0 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -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