mirror of
https://github.com/fluencelabs/redis
synced 2025-03-27 21:01:04 +00:00
check if *value is non-NULL before setting it
This commit is contained in:
parent
335d16bc0f
commit
33c1269efc
@ -87,13 +87,13 @@ unsigned char *ziplistPush(unsigned char *zl, unsigned char *entry, unsigned int
|
|||||||
unsigned char *ziplistPop(unsigned char *zl, sds *value, int where) {
|
unsigned char *ziplistPop(unsigned char *zl, sds *value, int where) {
|
||||||
unsigned int curlen = ZIPLIST_BYTES(zl), len, rlen;
|
unsigned int curlen = ZIPLIST_BYTES(zl), len, rlen;
|
||||||
unsigned char *p;
|
unsigned char *p;
|
||||||
*value = NULL;
|
if (value) *value = NULL;
|
||||||
|
|
||||||
/* Get pointer to element to remove */
|
/* Get pointer to element to remove */
|
||||||
p = (where == ZIPLIST_HEAD) ? ziplistHead(zl) : ziplistTail(zl);
|
p = (where == ZIPLIST_HEAD) ? ziplistHead(zl) : ziplistTail(zl);
|
||||||
if (*p == ZIP_END) return zl;
|
if (*p == ZIP_END) return zl;
|
||||||
len = zipDecodeLength(p);
|
len = zipDecodeLength(p);
|
||||||
*value = sdsnewlen(p+zipEncodeLength(NULL,len),len);
|
if (value) *value = sdsnewlen(p+zipEncodeLength(NULL,len),len);
|
||||||
|
|
||||||
/* Move list to front when popping from the head */
|
/* Move list to front when popping from the head */
|
||||||
rlen = zipRawEntryLength(p);
|
rlen = zipRawEntryLength(p);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user