From 6fc13d9595ef4972551c0dfa7920f8d87935388a Mon Sep 17 00:00:00 2001 From: Tim Peters Date: Tue, 2 Jul 2002 18:12:35 +0000 Subject: Finished transitioning to using gc_refs to track gc objects' states. This was mostly a matter of adding comments and light code rearrangement. Upon untracking, gc_next is still set to NULL. It's a cheap way to provoke memory faults if calling code is insane. It's also used in some way by the trashcan mechanism. --- Include/objimpl.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Include/objimpl.h') diff --git a/Include/objimpl.h b/Include/objimpl.h index 28f3661574..3a7488a322 100644 --- a/Include/objimpl.h +++ b/Include/objimpl.h @@ -251,7 +251,7 @@ extern DL_IMPORT(PyVarObject *) _PyObject_GC_Resize(PyVarObject *, int); /* GC information is stored BEFORE the object structure. */ typedef union _gc_head { struct { - union _gc_head *gc_next; /* not NULL if object is tracked */ + union _gc_head *gc_next; union _gc_head *gc_prev; int gc_refs; } gc; @@ -272,7 +272,6 @@ extern PyGC_Head *_PyGC_generation0; PyGC_Head *g = _Py_AS_GC(o); \ if (g->gc.gc_refs != _PyGC_REFS_UNTRACKED) \ Py_FatalError("GC object already tracked"); \ - assert(g->gc.gc_refs == _PyGC_REFS_UNTRACKED); \ g->gc.gc_refs = _PyGC_REFS_REACHABLE; \ g->gc.gc_next = _PyGC_generation0; \ g->gc.gc_prev = _PyGC_generation0->gc.gc_prev; \ @@ -280,7 +279,10 @@ extern PyGC_Head *_PyGC_generation0; _PyGC_generation0->gc.gc_prev = g; \ } while (0); -/* Tell the GC to stop tracking this object. */ +/* Tell the GC to stop tracking this object. + * gc_next doesn't need to be set to NULL, but doing so is a good + * way to provoke memory errors if calling code is confused. + */ #define _PyObject_GC_UNTRACK(o) do { \ PyGC_Head *g = _Py_AS_GC(o); \ assert(g->gc.gc_refs != _PyGC_REFS_UNTRACKED); \ -- cgit v1.2.1