mirror of
https://github.com/fluencelabs/redis
synced 2025-03-30 22:31:03 +00:00
two leaks fixed
This commit is contained in:
parent
beb7756dcb
commit
50a9fad5d5
27
src/t_zset.c
27
src/t_zset.c
@ -625,25 +625,23 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
* from small to large, all src[i > 0].dict are non-empty too */
|
* from small to large, all src[i > 0].dict are non-empty too */
|
||||||
di = dictGetIterator(src[0].dict);
|
di = dictGetIterator(src[0].dict);
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
double *score = zmalloc(sizeof(double)), value;
|
double score, value;
|
||||||
*score = src[0].weight * zunionInterDictValue(de);
|
|
||||||
|
|
||||||
|
score = src[0].weight * zunionInterDictValue(de);
|
||||||
for (j = 1; j < setnum; j++) {
|
for (j = 1; j < setnum; j++) {
|
||||||
dictEntry *other = dictFind(src[j].dict,dictGetEntryKey(de));
|
dictEntry *other = dictFind(src[j].dict,dictGetEntryKey(de));
|
||||||
if (other) {
|
if (other) {
|
||||||
value = src[j].weight * zunionInterDictValue(other);
|
value = src[j].weight * zunionInterDictValue(other);
|
||||||
zunionInterAggregate(score, value, aggregate);
|
zunionInterAggregate(&score, value, aggregate);
|
||||||
} else {
|
} else {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* skip entry when not present in every source dict */
|
/* accept entry only when present in every source dict */
|
||||||
if (j != setnum) {
|
if (j == setnum) {
|
||||||
zfree(score);
|
|
||||||
} else {
|
|
||||||
robj *o = dictGetEntryKey(de);
|
robj *o = dictGetEntryKey(de);
|
||||||
znode = zslInsert(dstzset->zsl,*score,o);
|
znode = zslInsert(dstzset->zsl,score,o);
|
||||||
incrRefCount(o); /* added to skiplist */
|
incrRefCount(o); /* added to skiplist */
|
||||||
dictAdd(dstzset->dict,o,&znode->score);
|
dictAdd(dstzset->dict,o,&znode->score);
|
||||||
incrRefCount(o); /* added to dictionary */
|
incrRefCount(o); /* added to dictionary */
|
||||||
@ -657,11 +655,12 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
|
|
||||||
di = dictGetIterator(src[i].dict);
|
di = dictGetIterator(src[i].dict);
|
||||||
while((de = dictNext(di)) != NULL) {
|
while((de = dictNext(di)) != NULL) {
|
||||||
/* skip key when already processed */
|
double score, value;
|
||||||
if (dictFind(dstzset->dict,dictGetEntryKey(de)) != NULL) continue;
|
|
||||||
|
|
||||||
double *score = zmalloc(sizeof(double)), value;
|
/* skip key when already processed */
|
||||||
*score = src[i].weight * zunionInterDictValue(de);
|
if (dictFind(dstzset->dict,dictGetEntryKey(de)) != NULL)
|
||||||
|
continue;
|
||||||
|
score = src[i].weight * zunionInterDictValue(de);
|
||||||
|
|
||||||
/* because the zsets are sorted by size, its only possible
|
/* because the zsets are sorted by size, its only possible
|
||||||
* for sets at larger indices to hold this entry */
|
* for sets at larger indices to hold this entry */
|
||||||
@ -669,12 +668,12 @@ void zunionInterGenericCommand(redisClient *c, robj *dstkey, int op) {
|
|||||||
dictEntry *other = dictFind(src[j].dict,dictGetEntryKey(de));
|
dictEntry *other = dictFind(src[j].dict,dictGetEntryKey(de));
|
||||||
if (other) {
|
if (other) {
|
||||||
value = src[j].weight * zunionInterDictValue(other);
|
value = src[j].weight * zunionInterDictValue(other);
|
||||||
zunionInterAggregate(score, value, aggregate);
|
zunionInterAggregate(&score, value, aggregate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
robj *o = dictGetEntryKey(de);
|
robj *o = dictGetEntryKey(de);
|
||||||
znode = zslInsert(dstzset->zsl,*score,o);
|
znode = zslInsert(dstzset->zsl,score,o);
|
||||||
incrRefCount(o); /* added to skiplist */
|
incrRefCount(o); /* added to skiplist */
|
||||||
dictAdd(dstzset->dict,o,&znode->score);
|
dictAdd(dstzset->dict,o,&znode->score);
|
||||||
incrRefCount(o); /* added to dictionary */
|
incrRefCount(o); /* added to dictionary */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user