Skip to content

Commit

Permalink
Resolved test error and clippy error
Browse files Browse the repository at this point in the history
  • Loading branch information
JulianSchmid committed Nov 13, 2023
1 parent 5908f2f commit 9593a03
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
9 changes: 4 additions & 5 deletions src/tp_buf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,14 +193,13 @@ impl TpBuf {
// get enough memory to store a SOMEIP header + tp reassembled payload
let required_len = SOMEIP_HEADER_LENGTH + (tp_header.offset() as usize) + payload.len();
if self.data.len() < required_len {
if self.data.capacity() < required_len {
if self
if self.data.capacity() < required_len
&& self
.data
.try_reserve(required_len - self.data.len())
.is_err()
{
return Err(AllocationFailure { len: required_len });
}
{
return Err(AllocationFailure { len: required_len });
}
unsafe {
self.data.set_len(required_len);
Expand Down
7 changes: 5 additions & 2 deletions src/tp_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ where
}
}

pub fn with_capacity(buf_config: TpBufConfig, initial_bufs_count: usize) -> TpPool<ChannelId, Timestamp> {
pub fn with_capacity(
buf_config: TpBufConfig,
initial_bufs_count: usize,
) -> TpPool<ChannelId, Timestamp> {
TpPool {
active: HashMap::with_capacity(initial_bufs_count),
finished: {
Expand All @@ -63,7 +66,7 @@ where
for _ in 0..additional {
self.finished.push(TpBuf::new(self.buf_config.clone()));
}
self.active.reserve(additional);
self.active.reserve(self.finished.len());
}

#[inline]
Expand Down

0 comments on commit 9593a03

Please sign in to comment.