Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
e1b8b4b6
Commit
e1b8b4b6
authored
Jul 11, 2017
by
antirez
Browse files
CLUSTER GETKEYSINSLOT: avoid overallocating.
Close #3911.
parent
5bd46d33
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/cluster.c
View file @
e1b8b4b6
...
...
@@ -4380,6 +4380,11 @@ void clusterCommand(client *c) {
return
;
}
/* Avoid allocating more than needed in case of large COUNT argument
* and smaller actual number of keys. */
unsigned
int
keys_in_slot
=
countKeysInSlot
(
slot
);
if
(
maxkeys
>
keys_in_slot
)
maxkeys
=
keys_in_slot
;
keys
=
zmalloc
(
sizeof
(
robj
*
)
*
maxkeys
);
numkeys
=
getKeysInSlot
(
slot
,
keys
,
maxkeys
);
addReplyMultiBulkLen
(
c
,
numkeys
);
...
...
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