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

Function lpPrev

src/listpack.c:466–475  ·  view source on GitHub ↗

If 'p' points to an element of the listpack, calling lpPrev() will return * the pointer to the previous element (the one on the left), or NULL if 'p' * already pointed to the first element of the listpack. */

Source from the content-addressed store, hash-verified

464 * the pointer to the previous element (the one on the left), or NULL if 'p'
465 * already pointed to the first element of the listpack. */
466unsigned char *lpPrev(unsigned char *lp, unsigned char *p) {
467 assert(p);
468 if (p-lp == LP_HDR_SIZE) return NULL;
469 p--; /* Seek the first backlen byte of the last element. */
470 uint64_t prevlen = lpDecodeBacklen(p);
471 prevlen += lpEncodeBacklen(NULL,prevlen);
472 p -= prevlen-1; /* Seek the first byte of the previous entry. */
473 lpAssertValidEntry(lp, lpBytes(lp), p);
474 return p;
475}
476
477/* Return a pointer to the first element of the listpack, or NULL if the
478 * listpack has no elements. */

Callers 4

lpLastFunction · 0.85
lpSeekFunction · 0.85
lpGetEdgeStreamIDFunction · 0.85
streamIteratorGetIDFunction · 0.85

Calls 4

lpDecodeBacklenFunction · 0.85
lpEncodeBacklenFunction · 0.85
lpAssertValidEntryFunction · 0.85
lpBytesFunction · 0.85

Tested by

no test coverage detected