Skip to content

Commit f7782f8

Browse files
committed
py/gc: For finaliser, interpret a pointer into the heap as concrete obj.
1 parent 969e4bb commit f7782f8

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

py/gc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,16 +230,16 @@ STATIC void gc_sweep(void) {
230230
#endif
231231
// free unmarked heads and their tails
232232
int free_tail = 0;
233-
for (mp_uint_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) {
233+
for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) {
234234
switch (ATB_GET_KIND(block)) {
235235
case AT_HEAD:
236236
#if MICROPY_ENABLE_FINALISER
237237
if (FTB_GET(block)) {
238-
mp_obj_t obj = (mp_obj_t)PTR_FROM_BLOCK(block);
239-
if (((mp_obj_base_t*)MP_OBJ_TO_PTR(obj))->type != NULL) {
238+
mp_obj_base_t *obj = (mp_obj_base_t*)PTR_FROM_BLOCK(block);
239+
if (obj->type != NULL) {
240240
// if the object has a type then see if it has a __del__ method
241241
mp_obj_t dest[2];
242-
mp_load_method_maybe(obj, MP_QSTR___del__, dest);
242+
mp_load_method_maybe(MP_OBJ_FROM_PTR(obj), MP_QSTR___del__, dest);
243243
if (dest[0] != MP_OBJ_NULL) {
244244
// load_method returned a method
245245
mp_call_method_n_kw(0, 0, dest);

0 commit comments

Comments
 (0)