MCPcopy Create free account
hub / github.com/F-Stack/f-stack / quicklistDelEntry

Function quicklistDelEntry

app/redis-6.2.6/src/quicklist.c:658–685  ·  view source on GitHub ↗

Delete one element represented by 'entry' * * 'entry' stores enough metadata to delete the proper position in * the correct ziplist in the correct quicklist node. */

Source from the content-addressed store, hash-verified

656 * 'entry' stores enough metadata to delete the proper position in
657 * the correct ziplist in the correct quicklist node. */
658void quicklistDelEntry(quicklistIter *iter, quicklistEntry *entry) {
659 quicklistNode *prev = entry->node->prev;
660 quicklistNode *next = entry->node->next;
661 int deleted_node = quicklistDelIndex((quicklist *)entry->quicklist,
662 entry->node, &entry->zi);
663
664 /* after delete, the zi is now invalid for any future usage. */
665 iter->zi = NULL;
666
667 /* If current node is deleted, we must update iterator node and offset. */
668 if (deleted_node) {
669 if (iter->direction == AL_START_HEAD) {
670 iter->current = next;
671 iter->offset = 0;
672 } else if (iter->direction == AL_START_TAIL) {
673 iter->current = prev;
674 iter->offset = -1;
675 }
676 }
677 /* else if (!deleted_node), no changes needed.
678 * we already reset iter->zi above, and the existing iter->offset
679 * doesn't move again because:
680 * - [1, 2, 3] => delete offset 1 => [1, 3]: next element still offset 1
681 * - [1, 2, 3] => delete offset 0 => [2, 3]: next element still offset 0
682 * if we deleted the last element at offet N and now
683 * length of this ziplist is N-1, the next call into
684 * quicklistNext() will jump to the next node. */
685}
686
687/* Replace quicklist entry at offset 'index' by 'data' with length 'sz'.
688 *

Callers 2

quicklistTestFunction · 0.85
listTypeDeleteFunction · 0.85

Calls 1

quicklistDelIndexFunction · 0.85

Tested by

no test coverage detected