summaryrefslogtreecommitdiffstatshomepage
path: root/py/malloc.c
diff options
context:
space:
mode:
Diffstat (limited to 'py/malloc.c')
-rw-r--r--py/malloc.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/py/malloc.c b/py/malloc.c
index f8728c5964..0aecbd71d4 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -56,7 +56,10 @@
#define malloc(b) gc_alloc((b), false)
#define malloc_with_finaliser(b) gc_alloc((b), true)
#define free gc_free
-#define realloc gc_realloc
+#define realloc(ptr, n) gc_realloc(ptr, n, true)
+#define realloc_ext(ptr, n, mv) gc_realloc(ptr, n, mv)
+#else
+#define realloc_ext(ptr, n, mv) realloc(ptr, n)
#endif // MICROPY_ENABLE_GC
void *m_malloc(size_t num_bytes) {
@@ -134,11 +137,11 @@ void *m_realloc(void *ptr, size_t new_num_bytes) {
}
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
-void *m_realloc_maybe(void *ptr, size_t old_num_bytes, size_t new_num_bytes) {
+void *m_realloc_maybe(void *ptr, size_t old_num_bytes, size_t new_num_bytes, bool allow_move) {
#else
-void *m_realloc_maybe(void *ptr, size_t new_num_bytes) {
+void *m_realloc_maybe(void *ptr, size_t new_num_bytes, bool allow_move) {
#endif
- void *new_ptr = realloc(ptr, new_num_bytes);
+ void *new_ptr = realloc_ext(ptr, new_num_bytes, allow_move);
#if MICROPY_MEM_STATS
// At first thought, "Total bytes allocated" should only grow,
// after all, it's *total*. But consider for example 2K block