Skip to content

Commit 25788c1

Browse files
committed
FIX: bug in offset() calculation
Off-By-One error when rouding to the next offset. I totally missed that a bug slipped into the offset calculation because I only tested with u8 and i32 data.
1 parent 9713321 commit 25788c1

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -381,7 +381,7 @@ impl<H, T> HeaderVec<H, T> {
381381
const fn offset() -> usize {
382382
// The first location, in units of size_of::<T>(), that is after the header
383383
// It's the end of the header, rounded up to the nearest size_of::<T>()
384-
mem::size_of::<AlignedHeader<H, T>>() / mem::size_of::<T>()
384+
(mem::size_of::<AlignedHeader<H, T>>()-1) / mem::size_of::<T>() + 1
385385
}
386386

387387
/// Compute the number of elements (in units of T) to allocate for a given capacity.

0 commit comments

Comments
 (0)