Commit d875bf6
Fix leak when shrinking a hashtable without entries (#2288)
Fixes #2271
When we shrink a hash table and it is empty, we do it without iterating
over it to rehash the entries. However, there may still be empty child
buckets (`used[0]==0 && child_buckets[0]!=0`). These were leaked in this
case.
This fix is to check for child buckets and don't skip the incremental
rehashing if any child buckets exist. The incremental rehashing pass
will free them.
An additional fix is to compact bucket chains in scan when the scan
callback has deleted some entries. This was already implemented for the
case when rehashing is ongoing but it was missing in the case rehashing
is not ongoing.
Additionally, a test case for #2257 was added.
---------
Signed-off-by: yzc-yzc <[email protected]>
Co-authored-by: Viktor Söderqvist <[email protected]>
Co-authored-by: Yakov Gusakov <[email protected]>1 parent 2831722 commit d875bf6
2 files changed
+46
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
649 | 649 | | |
650 | 650 | | |
651 | 651 | | |
652 | | - | |
| 652 | + | |
653 | 653 | | |
654 | 654 | | |
655 | 655 | | |
| |||
1718 | 1718 | | |
1719 | 1719 | | |
1720 | 1720 | | |
1721 | | - | |
| 1721 | + | |
| 1722 | + | |
| 1723 | + | |
1722 | 1724 | | |
1723 | 1725 | | |
1724 | 1726 | | |
| |||
1736 | 1738 | | |
1737 | 1739 | | |
1738 | 1740 | | |
| 1741 | + | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
| 1745 | + | |
1739 | 1746 | | |
1740 | 1747 | | |
1741 | 1748 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
951 | 951 | | |
952 | 952 | | |
953 | 953 | | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
| 957 | + | |
| 958 | + | |
| 959 | + | |
| 960 | + | |
| 961 | + | |
| 962 | + | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
| 979 | + | |
| 980 | + | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
954 | 991 | | |
955 | 992 | | |
956 | 993 | | |
| |||
0 commit comments