Call gc_free in gc_realloc after allocating new block.
This commit is contained in:
parent
0f6545139b
commit
d2c1a732e5
2
py/gc.c
2
py/gc.c
@ -329,8 +329,10 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
|
|||||||
if (n_bytes <= n_existing) {
|
if (n_bytes <= n_existing) {
|
||||||
return ptr;
|
return ptr;
|
||||||
} else {
|
} else {
|
||||||
|
// TODO check if we can grow inplace
|
||||||
void *ptr2 = gc_alloc(n_bytes);
|
void *ptr2 = gc_alloc(n_bytes);
|
||||||
memcpy(ptr2, ptr, n_existing);
|
memcpy(ptr2, ptr, n_existing);
|
||||||
|
gc_free(ptr);
|
||||||
return ptr2;
|
return ptr2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user