summaryrefslogtreecommitdiffstatshomepage
path: root/py
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-04-20 11:43:38 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2014-04-20 13:08:33 +0300
commited162b5ef28537db62034d63ea8bf85aff035f03 (patch)
treebbb9a00625de819c5ed45a37f0506d718669dab9 /py
parent9fd02e186d86f42e51383b16878c96645db40d6e (diff)
downloadmicropython-ed162b5ef28537db62034d63ea8bf85aff035f03.tar.gz
micropython-ed162b5ef28537db62034d63ea8bf85aff035f03.zip
gc: Recover simple gc_realloc implementation, make easier to switch between.
Diffstat (limited to 'py')
-rw-r--r--py/gc.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/py/gc.c b/py/gc.c
index d39307464b..30f2bfbde7 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -434,8 +434,14 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
if (n_bytes <= n_existing) {
return ptr;
} else {
- // TODO check if we can grow inplace
- void *ptr2 = gc_alloc(n_bytes);
+ // TODO false is incorrect! Should get value from current block!
+ void *ptr2 = gc_alloc(n_bytes,
+#if MICROPY_ENABLE_FINALISER
+ FTB_GET(BLOCK_FROM_PTR((machine_uint_t)ptr))
+#else
+ false
+#endif
+ );
if (ptr2 == NULL) {
return ptr2;
}
@@ -444,7 +450,8 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
return ptr2;
}
}
-#endif
+
+#else // Alternative gc_realloc impl
void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
if (gc_lock_depth > 0) {
@@ -524,6 +531,7 @@ void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
return ptr_out;
}
+#endif // Alternative gc_realloc impl
void gc_dump_info() {
gc_info_t info;