From d2c1a732e5c04fce58eec5053ad04c3f29da16ba Mon Sep 17 00:00:00 2001
From: Damien <damien.p.george@gmail.com>
Date: Wed, 23 Oct 2013 21:03:27 +0100
Subject: [PATCH] Call gc_free in gc_realloc after allocating new block.

---
 py/gc.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/py/gc.c b/py/gc.c
index 7d4f4762ef..690503d92c 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -329,8 +329,10 @@ 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);
         memcpy(ptr2, ptr, n_existing);
+        gc_free(ptr);
         return ptr2;
     }
 }
-- 
GitLab