[Python-checkins] python/dist/src/Modules gcmodule.c,2.79,2.80

tim_one at users.sourceforge.net tim_one at users.sourceforge.net
Mon Nov 1 17:40:00 CET 2004


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26670/Modules

Modified Files:
	gcmodule.c 
Log Message:
gc_list_move():  Make this truly equivalent to remove+append.  While
nothing in gc currently cares, the original coding could screw up if,
e.g., you tried to move a node to the list it's already in, and the node
was already the last in its list.


Index: gcmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/gcmodule.c,v
retrieving revision 2.79
retrieving revision 2.80
diff -u -d -r2.79 -r2.80
--- gcmodule.c	1 Nov 2004 01:39:08 -0000	2.79
+++ gcmodule.c	1 Nov 2004 16:39:57 -0000	2.80
@@ -168,14 +168,16 @@
 static void
 gc_list_move(PyGC_Head *node, PyGC_Head *list)
 {
+	PyGC_Head *new_prev;
 	PyGC_Head *current_prev = node->gc.gc_prev;
 	PyGC_Head *current_next = node->gc.gc_next;
-	PyGC_Head *new_prev = list->gc.gc_prev;
+	/* Unlink from current list. */
 	current_prev->gc.gc_next = current_next;
 	current_next->gc.gc_prev = current_prev;
-	node->gc.gc_next = list;
-	node->gc.gc_prev = new_prev;
+	/* Relink at end of new list. */
+	new_prev = node->gc.gc_prev = list->gc.gc_prev;
 	new_prev->gc.gc_next = list->gc.gc_prev = node;
+	node->gc.gc_next = list;
 }
 
 /* append list `from` onto list `to`; `from` becomes an empty list */



More information about the Python-checkins mailing list