File tree 1 file changed +19
-10
lines changed
1 file changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -2443,6 +2443,23 @@ PyObject_GC_IsFinalized(PyObject *obj)
2443
2443
return 0 ;
2444
2444
}
2445
2445
2446
+ static int
2447
+ visit_generation (gcvisitobjects_t callback , void * arg , struct gc_generation * gen )
2448
+ {
2449
+ PyGC_Head * gc_list , * gc ;
2450
+ gc_list = & gen -> head ;
2451
+ for (gc = GC_NEXT (gc_list ); gc != gc_list ; gc = GC_NEXT (gc )) {
2452
+ PyObject * op = FROM_GC (gc );
2453
+ Py_INCREF (op );
2454
+ int res = callback (op , arg );
2455
+ Py_DECREF (op );
2456
+ if (!res ) {
2457
+ return -1 ;
2458
+ }
2459
+ }
2460
+ return 0 ;
2461
+ }
2462
+
2446
2463
void
2447
2464
PyUnstable_GC_VisitObjects (gcvisitobjects_t callback , void * arg )
2448
2465
{
@@ -2451,16 +2468,8 @@ PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg)
2451
2468
int origenstate = gcstate -> enabled ;
2452
2469
gcstate -> enabled = 0 ;
2453
2470
for (i = 0 ; i < NUM_GENERATIONS ; i ++ ) {
2454
- PyGC_Head * gc_list , * gc ;
2455
- gc_list = GEN_HEAD (gcstate , i );
2456
- for (gc = GC_NEXT (gc_list ); gc != gc_list ; gc = GC_NEXT (gc )) {
2457
- PyObject * op = FROM_GC (gc );
2458
- Py_INCREF (op );
2459
- int res = callback (op , arg );
2460
- Py_DECREF (op );
2461
- if (!res ) {
2462
- goto done ;
2463
- }
2471
+ if (visit_generation (callback , arg , & gcstate -> generations [i ])) {
2472
+ goto done ;
2464
2473
}
2465
2474
}
2466
2475
done :
You can’t perform that action at this time.
0 commit comments