File tree Expand file tree Collapse file tree 1 file changed +19
-10
lines changed Expand file tree Collapse file tree 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)
24432443 return 0 ;
24442444}
24452445
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+
24462463void
24472464PyUnstable_GC_VisitObjects (gcvisitobjects_t callback , void * arg )
24482465{
@@ -2451,16 +2468,8 @@ PyUnstable_GC_VisitObjects(gcvisitobjects_t callback, void *arg)
24512468 int origenstate = gcstate -> enabled ;
24522469 gcstate -> enabled = 0 ;
24532470 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 ;
24642473 }
24652474 }
24662475done :
You can’t perform that action at this time.
0 commit comments