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
3b9495d2
Commit
3b9495d2
authored
Jul 08, 2016
by
antirez
Browse files
LRU: use C99 variable len stack array in evictionPoolPopulate().
parent
2a124730
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/evict.c
View file @
3b9495d2
...
...
@@ -115,16 +115,7 @@ struct evictionPoolEntry *evictionPoolAlloc(void) {
#define EVICTION_SAMPLES_ARRAY_SIZE 16
void
evictionPoolPopulate
(
dict
*
sampledict
,
dict
*
keydict
,
struct
evictionPoolEntry
*
pool
)
{
int
j
,
k
,
count
;
dictEntry
*
_samples
[
EVICTION_SAMPLES_ARRAY_SIZE
];
dictEntry
**
samples
;
/* Try to use a static buffer: this function is a big hit...
* Note: it was actually measured that this helps. */
if
(
server
.
maxmemory_samples
<=
EVICTION_SAMPLES_ARRAY_SIZE
)
{
samples
=
_samples
;
}
else
{
samples
=
zmalloc
(
sizeof
(
samples
[
0
])
*
server
.
maxmemory_samples
);
}
dictEntry
*
samples
[
server
.
maxmemory_samples
];
count
=
dictGetSomeKeys
(
sampledict
,
samples
,
server
.
maxmemory_samples
);
for
(
j
=
0
;
j
<
count
;
j
++
)
{
...
...
@@ -175,7 +166,6 @@ void evictionPoolPopulate(dict *sampledict, dict *keydict, struct evictionPoolEn
pool
[
k
].
key
=
sdsdup
(
key
);
pool
[
k
].
idle
=
idle
;
}
if
(
samples
!=
_samples
)
zfree
(
samples
);
}
int
freeMemoryIfNeeded
(
void
)
{
...
...
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