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

Function quicklistReplaceAtIndex

src/quicklist.c:691–703  ·  view source on GitHub ↗

Replace quicklist entry at offset 'index' by 'data' with length 'sz'. * * Returns 1 if replace happened. * Returns 0 if replace failed and no changes happened. */

Source from the content-addressed store, hash-verified

689 * Returns 1 if replace happened.
690 * Returns 0 if replace failed and no changes happened. */
691int quicklistReplaceAtIndex(quicklist *quicklist, long index, void *data,
692 int sz) {
693 quicklistEntry entry;
694 if (likely(quicklistIndex(quicklist, index, &entry))) {
695 /* quicklistIndex provides an uncompressed node */
696 entry.node->zl = ziplistReplace(entry.node->zl, entry.zi, data, sz);
697 quicklistNodeUpdateSz(entry.node);
698 quicklistCompress(quicklist, entry.node);
699 return 1;
700 } else {
701 return 0;
702 }
703}
704
705/* Given two nodes, try to merge their ziplists.
706 *

Callers 2

quicklistTestFunction · 0.85
lsetCommandFunction · 0.85

Calls 2

quicklistIndexFunction · 0.85
ziplistReplaceFunction · 0.85

Tested by

no test coverage detected