summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-03-07 00:21:51 +0000
committerDamien George <damien.p.george@gmail.com>2014-03-07 00:21:51 +0000
commit6fc765c928460ad8a116f8dd1b8b1412fb997829 (patch)
treefdb0570030debafac05305cabc1ba952e4fbc170
parentf08ddef676504dcbdc3c5b50f8dd28145dccc3f7 (diff)
downloadmicropython-6fc765c928460ad8a116f8dd1b8b1412fb997829.tar.gz
micropython-6fc765c928460ad8a116f8dd1b8b1412fb997829.zip
py: Revert to old gc_realloc for now.
-rw-r--r--py/gc.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/py/gc.c b/py/gc.c
index cf1bdfbc59..b4822ee29f 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -326,6 +326,24 @@ machine_uint_t gc_nbytes(void *ptr_in) {
return 0;
}
+// use this realloc for now, one below is broken
+void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
+ machine_uint_t n_existing = gc_nbytes(ptr);
+ if (n_bytes <= n_existing) {
+ return ptr;
+ } else {
+ // TODO check if we can grow inplace
+ void *ptr2 = gc_alloc(n_bytes);
+ if (ptr2 == NULL) {
+ return ptr2;
+ }
+ memcpy(ptr2, ptr, n_existing);
+ gc_free(ptr);
+ return ptr2;
+ }
+}
+
+#if 0
void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
void *ptr_out = NULL;
machine_uint_t block = 0;
@@ -395,6 +413,7 @@ void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
return ptr_out;
}
+#endif
void gc_dump_info() {
gc_info_t info;