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
1c7eb0ad
Unverified
Commit
1c7eb0ad
authored
Jan 18, 2024
by
Binbin
Committed by
GitHub
Jan 18, 2024
Browse files
Fix minor memory leaks in dictTest (#12962)
Introduced in #12952, reported by valgrind.
parent
0e5a4a27
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/dict.c
View file @
1c7eb0ad
...
@@ -1807,7 +1807,9 @@ int dictTest(int argc, char **argv, int flags) {
...
@@ -1807,7 +1807,9 @@ int dictTest(int argc, char **argv, int flags) {
/* Delete keys until 13 keys remain, now is 13:128, so we can
/* Delete keys until 13 keys remain, now is 13:128, so we can
* satisfy HASHTABLE_MIN_FILL in the next test. */
* satisfy HASHTABLE_MIN_FILL in the next test. */
for
(
j
=
0
;
j
<
68
;
j
++
)
{
for
(
j
=
0
;
j
<
68
;
j
++
)
{
retval
=
dictDelete
(
dict
,
stringFromLongLong
(
j
));
char
*
key
=
stringFromLongLong
(
j
);
retval
=
dictDelete
(
dict
,
key
);
zfree
(
key
);
assert
(
retval
==
DICT_OK
);
assert
(
retval
==
DICT_OK
);
}
}
assert
(
dictSize
(
dict
)
==
13
);
assert
(
dictSize
(
dict
)
==
13
);
...
@@ -1817,7 +1819,9 @@ int dictTest(int argc, char **argv, int flags) {
...
@@ -1817,7 +1819,9 @@ int dictTest(int argc, char **argv, int flags) {
}
}
TEST
(
"Delete one more key, trigger the dict resize"
)
{
TEST
(
"Delete one more key, trigger the dict resize"
)
{
retval
=
dictDelete
(
dict
,
stringFromLongLong
(
68
));
char
*
key
=
stringFromLongLong
(
68
);
retval
=
dictDelete
(
dict
,
key
);
zfree
(
key
);
assert
(
retval
==
DICT_OK
);
assert
(
retval
==
DICT_OK
);
assert
(
dictSize
(
dict
)
==
12
);
assert
(
dictSize
(
dict
)
==
12
);
assert
(
DICTHT_SIZE
(
dict
->
ht_size_exp
[
0
])
==
128
);
assert
(
DICTHT_SIZE
(
dict
->
ht_size_exp
[
0
])
==
128
);
...
@@ -1849,7 +1853,9 @@ int dictTest(int argc, char **argv, int flags) {
...
@@ -1849,7 +1853,9 @@ int dictTest(int argc, char **argv, int flags) {
* HASHTABLE_MIN_FILL / dict_force_resize_ratio. */
* HASHTABLE_MIN_FILL / dict_force_resize_ratio. */
dictSetResizeEnabled
(
DICT_RESIZE_AVOID
);
dictSetResizeEnabled
(
DICT_RESIZE_AVOID
);
for
(
j
=
0
;
j
<
125
;
j
++
)
{
for
(
j
=
0
;
j
<
125
;
j
++
)
{
retval
=
dictDelete
(
dict
,
stringFromLongLong
(
j
));
char
*
key
=
stringFromLongLong
(
j
);
retval
=
dictDelete
(
dict
,
key
);
zfree
(
key
);
assert
(
retval
==
DICT_OK
);
assert
(
retval
==
DICT_OK
);
}
}
assert
(
dictSize
(
dict
)
==
3
);
assert
(
dictSize
(
dict
)
==
3
);
...
@@ -1857,7 +1863,9 @@ int dictTest(int argc, char **argv, int flags) {
...
@@ -1857,7 +1863,9 @@ int dictTest(int argc, char **argv, int flags) {
}
}
TEST
(
"Delete one more key, trigger the dict resize"
)
{
TEST
(
"Delete one more key, trigger the dict resize"
)
{
retval
=
dictDelete
(
dict
,
stringFromLongLong
(
125
));
char
*
key
=
stringFromLongLong
(
125
);
retval
=
dictDelete
(
dict
,
key
);
zfree
(
key
);
assert
(
retval
==
DICT_OK
);
assert
(
retval
==
DICT_OK
);
assert
(
dictSize
(
dict
)
==
2
);
assert
(
dictSize
(
dict
)
==
2
);
assert
(
DICTHT_SIZE
(
dict
->
ht_size_exp
[
0
])
==
128
);
assert
(
DICTHT_SIZE
(
dict
->
ht_size_exp
[
0
])
==
128
);
...
...
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