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.
This commit is contained in:
parent
099ecfbec9
commit
bc1d1b80d1
@ -168,14 +168,16 @@ gc_list_remove(PyGC_Head *node)
|
|||||||
static void
|
static void
|
||||||
gc_list_move(PyGC_Head *node, PyGC_Head *list)
|
gc_list_move(PyGC_Head *node, PyGC_Head *list)
|
||||||
{
|
{
|
||||||
|
PyGC_Head *new_prev;
|
||||||
PyGC_Head *current_prev = node->gc.gc_prev;
|
PyGC_Head *current_prev = node->gc.gc_prev;
|
||||||
PyGC_Head *current_next = node->gc.gc_next;
|
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_prev->gc.gc_next = current_next;
|
||||||
current_next->gc.gc_prev = current_prev;
|
current_next->gc.gc_prev = current_prev;
|
||||||
node->gc.gc_next = list;
|
/* Relink at end of new list. */
|
||||||
node->gc.gc_prev = new_prev;
|
new_prev = node->gc.gc_prev = list->gc.gc_prev;
|
||||||
new_prev->gc.gc_next = list->gc.gc_prev = node;
|
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 */
|
/* append list `from` onto list `to`; `from` becomes an empty list */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user