Commit 2e464bf0 authored by Sun He's avatar Sun He Committed by antirez
Browse files

modules/RM_StringTruncate: correct reallocate condition

parent 3a7b1702
...@@ -747,7 +747,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) { ...@@ -747,7 +747,7 @@ int RM_StringTruncate(RedisModuleKey *key, size_t newlen) {
} else if (newlen < curlen) { } else if (newlen < curlen) {
sdsrange(key->value->ptr,0,newlen-1); sdsrange(key->value->ptr,0,newlen-1);
/* If the string is too wasteful, reallocate it. */ /* If the string is too wasteful, reallocate it. */
if (sdslen(key->value->ptr) > sdsavail(key->value->ptr)) if (sdslen(key->value->ptr) < sdsavail(key->value->ptr))
key->value->ptr = sdsRemoveFreeSpace(key->value->ptr); key->value->ptr = sdsRemoveFreeSpace(key->value->ptr);
} }
return REDISMODULE_OK; return REDISMODULE_OK;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment