Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
2e464bf0
Commit
2e464bf0
authored
Apr 06, 2016
by
Sun He
Committed by
antirez
May 10, 2016
Browse files
modules/RM_StringTruncate: correct reallocate condition
parent
3a7b1702
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
2e464bf0
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment