/* Store entry at current position in sds *value and return pointer
* to the next entry. */
-unsigned char *ziplistNext(unsigned char *p, unsigned char **entry, unsigned int *elen) {
+unsigned char *ziplistNext(unsigned char *p, unsigned char **q, unsigned char **entry, unsigned int *elen) {
if (*p == ZIP_END) return NULL;
if (entry) {
*elen = zipDecodeLength(p);
*entry = p+ZIP_LEN_BYTES(*elen);
}
+ if (q != NULL) *q = p;
p += zipRawEntryLength(p);
return p;
}
{
zl = createList();
p = ziplistIndex(zl, 0);
- while ((p = ziplistNext(p, &entry, &elen)) != NULL) {
+ while ((p = ziplistNext(p, NULL, &entry, &elen)) != NULL) {
printf("Entry: ");
fwrite(entry,elen,1,stdout);
printf(" (length %d)\n", elen);
{
zl = createList();
p = ziplistIndex(zl, 1);
- while ((p = ziplistNext(p, &entry, &elen)) != NULL) {
+ while ((p = ziplistNext(p, NULL, &entry, &elen)) != NULL) {
printf("Entry: ");
fwrite(entry,elen,1,stdout);
printf(" (length %d)\n", elen);
{
zl = createList();
p = ziplistIndex(zl, 2);
- while ((p = ziplistNext(p, &entry, &elen)) != NULL) {
+ while ((p = ziplistNext(p, NULL, &entry, &elen)) != NULL) {
printf("Entry: ");
fwrite(entry,elen,1,stdout);
printf(" (length %d)\n", elen);
{
zl = createList();
p = ziplistIndex(zl, 3);
- if (ziplistNext(p, &entry, &elen) == NULL) {
+ if (ziplistNext(p, &entry, NULL, &elen) == NULL) {
printf("No entry\n");
} else {
printf("ERROR\n");