diff options
author | Tim Peters <tim.peters@gmail.com> | 2002-07-02 18:12:35 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2002-07-02 18:12:35 (GMT) |
commit | 6fc13d9595ef4972551c0dfa7920f8d87935388a (patch) | |
tree | e43da2165025da7146c5ea611b94a44439c3b42a /Include | |
parent | 8e8dc419d0f6d28ff945190dc1e1384e04979a77 (diff) | |
download | cpython-6fc13d9595ef4972551c0dfa7920f8d87935388a.zip cpython-6fc13d9595ef4972551c0dfa7920f8d87935388a.tar.gz cpython-6fc13d9595ef4972551c0dfa7920f8d87935388a.tar.bz2 |
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.
Diffstat (limited to 'Include')
-rw-r--r-- | Include/objimpl.h | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/Include/objimpl.h b/Include/objimpl.h index 28f3661..3a7488a 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); \ |