[Python-checkins] python/dist/src/Modules gcmodule.c,2.41,2.42
nascheme@sourceforge.net
nascheme@sourceforge.net
Tue, 21 May 2002 08:53:27 -0700
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv11047
Modified Files:
gcmodule.c
Log Message:
Add IS_TRACKED and IS_MOVED macros. This makes a little more clear.
Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.41
retrieving revision 2.42
diff -C2 -d -r2.41 -r2.42
*** gcmodule.c 4 May 2002 05:35:20 -0000 2.41
--- gcmodule.c 21 May 2002 15:53:24 -0000 2.42
***************
*** 29,32 ****
--- 29,34 ----
#define FROM_GC(g) ((PyObject *)(((PyGC_Head *)g)+1))
+ /* True if an object is tracked by the GC */
+ #define IS_TRACKED(o) ((AS_GC(o))->gc.gc_next != NULL)
/*** Global GC state ***/
***************
*** 74,77 ****
--- 76,82 ----
#define GC_MOVED -123
+ /* True if an object has been moved to the older generation */
+ #define IS_MOVED(o) ((AS_GC(o))->gc.gc_refs == GC_MOVED)
+
/* list of uncollectable objects */
static PyObject *garbage;
***************
*** 171,176 ****
{
if (op && PyObject_IS_GC(op)) {
! PyGC_Head *gc = AS_GC(op);
! if (gc->gc.gc_next != NULL)
AS_GC(op)->gc.gc_refs--;
}
--- 176,180 ----
{
if (op && PyObject_IS_GC(op)) {
! if (IS_TRACKED(op))
AS_GC(op)->gc.gc_refs--;
}
***************
*** 213,218 ****
{
if (PyObject_IS_GC(op)) {
! PyGC_Head *gc = AS_GC(op);
! if (gc->gc.gc_next != NULL && gc->gc.gc_refs != GC_MOVED) {
gc_list_remove(gc);
gc_list_append(gc, tolist);
--- 217,222 ----
{
if (PyObject_IS_GC(op)) {
! if (IS_TRACKED(op) && !IS_MOVED(op)) {
! PyGC_Head *gc = AS_GC(op);
gc_list_remove(gc);
gc_list_append(gc, tolist);
***************
*** 857,862 ****
{
#ifdef WITH_CYCLE_GC
! PyGC_Head *gc = AS_GC(op);
! if (gc->gc.gc_next != NULL)
_PyObject_GC_UNTRACK(op);
#endif
--- 861,865 ----
{
#ifdef WITH_CYCLE_GC
! if (IS_TRACKED(op))
_PyObject_GC_UNTRACK(op);
#endif
***************
*** 942,946 ****
#ifdef WITH_CYCLE_GC
PyGC_Head *g = AS_GC(op);
! if (g->gc.gc_next != NULL)
gc_list_remove(g);
if (generations[0].count > 0) {
--- 945,949 ----
#ifdef WITH_CYCLE_GC
PyGC_Head *g = AS_GC(op);
! if (IS_TRACKED(op))
gc_list_remove(g);
if (generations[0].count > 0) {