mirror of
https://github.com/fluencelabs/redis
synced 2025-03-19 17:10:50 +00:00
Streams: free lp if all elements are deleted
This commit is contained in:
parent
ab33bcd346
commit
c9324f81a2
@ -705,10 +705,15 @@ void streamIteratorRemoveEntry(streamIterator *si, streamID *current) {
|
|||||||
/* Change the valid/deleted entries count in the master entry. */
|
/* Change the valid/deleted entries count in the master entry. */
|
||||||
unsigned char *p = lpFirst(lp);
|
unsigned char *p = lpFirst(lp);
|
||||||
aux = lpGetInteger(p);
|
aux = lpGetInteger(p);
|
||||||
|
if (aux == 1) {
|
||||||
|
lpFree(lp);
|
||||||
|
raxRemove(si->stream->rax,si->ri.key,si->ri.key_len,NULL);
|
||||||
|
} else {
|
||||||
lp = lpReplaceInteger(lp,&p,aux-1);
|
lp = lpReplaceInteger(lp,&p,aux-1);
|
||||||
p = lpNext(lp,p); /* Seek deleted field. */
|
p = lpNext(lp,p); /* Seek deleted field. */
|
||||||
aux = lpGetInteger(p);
|
aux = lpGetInteger(p);
|
||||||
lp = lpReplaceInteger(lp,&p,aux+1);
|
lp = lpReplaceInteger(lp,&p,aux+1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Update the number of entries counter. */
|
/* Update the number of entries counter. */
|
||||||
si->stream->length--;
|
si->stream->length--;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user