Skip to content

Commit c3b7dc8

Browse files
committed
Fix vector capacity calculation
1 parent 8851920 commit c3b7dc8

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

talpid-wireguard/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1077,7 +1077,7 @@ fn mtu_spacing(mtu_min: u16, mtu_max: u16, step_size: u16) -> Vec<u16> {
10771077
}
10781078
let second_mtu = mtu_min.next_multiple_of(step_size);
10791079
let in_between = (second_mtu..mtu_max).step_by(step_size as usize);
1080-
let mut ret = Vec::with_capacity(((mtu_max - mtu_min) / 3 + 2) as usize);
1080+
let mut ret = Vec::with_capacity(((mtu_max - second_mtu).div_ceil(step_size) + 2) as usize);
10811081
ret.push(mtu_min);
10821082
ret.extend(in_between);
10831083
ret.push(mtu_max);

0 commit comments

Comments
 (0)