Skip to content

Commit

Permalink
make memory usage consistent of robj with OBJ_ENCODING_INT
Browse files Browse the repository at this point in the history
  • Loading branch information
chendianqiang authored and antirez committed Jul 31, 2019
1 parent 436ed56 commit 2f8a074
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/object.c
Expand Up @@ -467,10 +467,15 @@ robj *tryObjectEncoding(robj *o) {
incrRefCount(shared.integers[value]);
return shared.integers[value];
} else {
if (o->encoding == OBJ_ENCODING_RAW) sdsfree(o->ptr);
o->encoding = OBJ_ENCODING_INT;
o->ptr = (void*) value;
return o;
if (o->encoding == OBJ_ENCODING_RAW) {
sdsfree(o->ptr);
o->encoding = OBJ_ENCODING_INT;
o->ptr = (void*) value;
return o;
} else {
decrRefCount(o);
return createStringObjectFromLongLongForValue(value);
}
}
}

Expand Down

0 comments on commit 2f8a074

Please sign in to comment.