Skip to content

Commit aa017a5

Browse files
committed
fix ZST check in Pool::grow
Node<T> always has non-zero size; we want to check the size of the data T
1 parent 0717a8c commit aa017a5

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/pool/mod.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,12 @@ impl<T> Pool<T> {
350350
///
351351
/// This method returns the number of *new* blocks that can be allocated.
352352
pub fn grow(&self, memory: &'static mut [u8]) -> usize {
353-
let sz = mem::size_of::<Node<T>>();
354-
355-
if sz == 0 {
356-
// SZT use no memory so a pool of SZT always has maximum capacity
353+
if mem::size_of::<T>() == 0 {
354+
// ZST use no memory so a pool of ZST always has maximum capacity
357355
return usize::max_value();
358356
}
359357

358+
let sz = mem::size_of::<Node<T>>();
360359
let mut p = memory.as_mut_ptr();
361360
let mut len = memory.len();
362361

0 commit comments

Comments
 (0)