MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / __quicklistDelNode

Function __quicklistDelNode

src/quicklist.c:593–627  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

591 } while (0)
592
593REDIS_STATIC void __quicklistDelNode(quicklist *quicklist,
594 quicklistNode *node) {
595 /* Update the bookmark if any */
596 quicklistBookmark *bm = _quicklistBookmarkFindByNode(quicklist, node);
597 if (bm) {
598 bm->node = node->next;
599 /* if the bookmark was to the last node, delete it. */
600 if (!bm->node)
601 _quicklistBookmarkDelete(quicklist, bm);
602 }
603
604 if (node->next)
605 node->next->prev = node->prev;
606 if (node->prev)
607 node->prev->next = node->next;
608
609 if (node == quicklist->tail) {
610 quicklist->tail = node->prev;
611 }
612
613 if (node == quicklist->head) {
614 quicklist->head = node->next;
615 }
616
617 /* Update len first, so in __quicklistCompress we know exactly len */
618 quicklist->len--;
619 quicklist->count -= node->count;
620
621 /* If we deleted a node within our compress depth, we
622 * now have compressed nodes needing to be decompressed. */
623 __quicklistCompress(quicklist, NULL);
624
625 zfree(node->zl);
626 zfree(node);
627}
628
629/* Delete one entry from list given the node for the entry and a pointer
630 * to the entry in the node.

Callers 3

quicklistDelIndexFunction · 0.85
_quicklistZiplistMergeFunction · 0.85
quicklistDelRangeFunction · 0.85

Calls 4

_quicklistBookmarkDeleteFunction · 0.85
__quicklistCompressFunction · 0.85
zfreeFunction · 0.85

Tested by

no test coverage detected