return (p[0] == ZIP_END) ? NULL : p+zipRawEntryLength(p);
}
+/* Return pointer to previous entry in ziplist. */
+unsigned char *ziplistPrev(unsigned char *p) {
+ zlentry entry = zipEntry(p);
+ return (entry.prevrawlen == 0) ? NULL : p-entry.prevrawlen;
+}
+
/* Get entry pointer to by 'p' and store in either 'e' or 'v' depending
* on the encoding of the entry. 'e' is always set to NULL to be able
* to find out whether the string pointer or the integer value was set.
return 1;
}
-/* Delete a range of entries from the ziplist. */
-unsigned char *ziplistDeleteRange(unsigned char *zl, unsigned int index, unsigned int num) {
- unsigned char *p = ziplistIndex(zl,index);
- return p == NULL ? zl : __ziplistDelete(zl,p,num);
+/* Insert an entry at "p". */
+unsigned char *ziplistInsert(unsigned char *zl, unsigned char *p, char *s, unsigned int slen) {
+ return __ziplistInsert(zl,p,s,slen);
}
/* Delete a single entry from the ziplist, pointed to by *p.
return zl;
}
+/* Delete a range of entries from the ziplist. */
+unsigned char *ziplistDeleteRange(unsigned char *zl, unsigned int index, unsigned int num) {
+ unsigned char *p = ziplistIndex(zl,index);
+ return (p == NULL) ? zl : __ziplistDelete(zl,p,num);
+}
+
/* Compare entry pointer to by 'p' with 'entry'. Return 1 if equal. */
unsigned int ziplistCompare(unsigned char *p, char *sstr, unsigned int slen) {
zlentry entry;
unsigned char *ziplistPop(unsigned char *zl, sds *target, int where);
unsigned char *ziplistIndex(unsigned char *zl, int index);
unsigned char *ziplistNext(unsigned char *p);
+unsigned char *ziplistPrev(unsigned char *p);
unsigned int ziplistGet(unsigned char *p, char **sstr, unsigned int *slen, long long *sval);
unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p);
+unsigned char *ziplistInsert(unsigned char *zl, unsigned char *p, char *s, unsigned int slen);
unsigned char *ziplistDeleteRange(unsigned char *zl, unsigned int index, unsigned int num);
unsigned int ziplistCompare(unsigned char *p, char *entry, unsigned int elen);
unsigned int ziplistLen(unsigned char *zl);