gc: Recover simple gc_realloc implementation, make easier to switch between.
This commit is contained in:
parent
9fd02e186d
commit
ed162b5ef2
14
py/gc.c
14
py/gc.c
@ -434,8 +434,14 @@ 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
|
// TODO false is incorrect! Should get value from current block!
|
||||||
void *ptr2 = gc_alloc(n_bytes);
|
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) {
|
if (ptr2 == NULL) {
|
||||||
return ptr2;
|
return ptr2;
|
||||||
}
|
}
|
||||||
@ -444,7 +450,8 @@ void *gc_realloc(void *ptr, machine_uint_t n_bytes) {
|
|||||||
return ptr2;
|
return ptr2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
#else // Alternative gc_realloc impl
|
||||||
|
|
||||||
void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
|
void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
|
||||||
if (gc_lock_depth > 0) {
|
if (gc_lock_depth > 0) {
|
||||||
@ -524,6 +531,7 @@ void *gc_realloc(void *ptr_in, machine_uint_t n_bytes) {
|
|||||||
|
|
||||||
return ptr_out;
|
return ptr_out;
|
||||||
}
|
}
|
||||||
|
#endif // Alternative gc_realloc impl
|
||||||
|
|
||||||
void gc_dump_info() {
|
void gc_dump_info() {
|
||||||
gc_info_t info;
|
gc_info_t info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user