Skip to content

Commit

Permalink
BUG: Traverse more thoroughly.
Browse files Browse the repository at this point in the history
  • Loading branch information
congma committed Mar 23, 2021
1 parent 5415c99 commit 638b21d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/lrudict.c
Original file line number Diff line number Diff line change
Expand Up @@ -1747,18 +1747,22 @@ LRU_fini(LRUDict *self)
static int
LRU_traverse(LRUDict *self, visitproc visit, void *arg)
{
Node *cur = FIRST_NODE(self);
PyObject *key;
Node *cur;
Py_ssize_t pos = 0;

while (IS_VALID_NODE_IN(self, cur)) {
Py_VISIT(cur->pl.key);
while(PyDict_Next(self->dict, &pos, &key, (PyObject **)&cur)) {
Py_VISIT(key);
if (cur->pl.key != key) {
Py_VISIT(cur->pl.key);
}
Py_VISIT(cur->pl.value);
cur = cur->next;
}

if (self->purge_queue && self->purge_queue->lst) {
Py_ssize_t len = PyList_Size(self->purge_queue->lst);
for (Py_ssize_t i = 0; i < len; i++) {
cur = (Node *)PyList_GET_ITEM(self->purge_queue->lst, i);
for (pos = 0; pos < len; pos++) {
Node *cur = (Node *)PyList_GET_ITEM(self->purge_queue->lst, pos);
if (cur) {
Py_VISIT(cur->pl.key);
Py_VISIT(cur->pl.value);
Expand Down

0 comments on commit 638b21d

Please sign in to comment.