From 6a8e35ad9252f1ea1ff0a449af52aef1f71815f8 Mon Sep 17 00:00:00 2001 From: Pieter Noordhuis Date: Mon, 31 May 2010 20:18:23 +0200 Subject: [PATCH] ziplistDelete no longer needs a direction now ziplistPrev is fixed --- ziplist.c | 8 ++------ ziplist.h | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/ziplist.c b/ziplist.c index 2aeffa41..dd94f14e 100644 --- a/ziplist.c +++ b/ziplist.c @@ -482,7 +482,7 @@ unsigned char *ziplistInsert(unsigned char *zl, unsigned char *p, char *s, unsig /* Delete a single entry from the ziplist, pointed to by *p. * Also update *p in place, to be able to iterate over the * ziplist, while deleting entries. */ -unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p, int direction) { +unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p) { unsigned int offset = *p-zl; zl = __ziplistDelete(zl,*p,1); @@ -490,11 +490,7 @@ unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p, int direction * do a realloc which might result in a different "zl"-pointer. * When the delete direction is back to front, we might delete the last * entry and end up with "p" pointing to ZIP_END, so check this. */ - if (*(zl+offset) == ZIP_END && direction == ZIPLIST_HEAD) { - *p = ZIPLIST_ENTRY_TAIL(zl); - } else { - *p = zl+offset; - } + *p = zl+offset; return zl; } diff --git a/ziplist.h b/ziplist.h index 15153fea..e8522182 100644 --- a/ziplist.h +++ b/ziplist.h @@ -9,7 +9,7 @@ unsigned char *ziplistNext(unsigned char *zl, unsigned char *p); unsigned char *ziplistPrev(unsigned char *zl, unsigned char *p); unsigned int ziplistGet(unsigned char *p, char **sstr, unsigned int *slen, long long *sval); unsigned char *ziplistInsert(unsigned char *zl, unsigned char *p, char *s, unsigned int slen); -unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p, int direction); +unsigned char *ziplistDelete(unsigned char *zl, unsigned char **p); 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); -- GitLab