Merge pull request #6261 from chendq8/robj

make memory usage consistent of robj with OBJ_ENCODING_INT
This commit is contained in:
Salvatore Sanfilippo 2019-07-31 11:54:11 +02:00 committed by GitHub
commit f899c31fbc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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);
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);
}
}
}