diff --git a/src/util.rs b/src/util.rs index 03d401f94..f707ee9d1 100644 --- a/src/util.rs +++ b/src/util.rs @@ -26,10 +26,8 @@ pub(crate) fn check_null_bytes(data: &[u8]) -> Result { } /// This function copies the slice into a vec and appends an element to its end. -/// The vec is allocated with reserve_exact. pub(crate) fn copy_and_push(data: &[T], to_push: T) -> alloc::vec::Vec { - let mut copy = alloc::vec::Vec::new(); - copy.reserve_exact(data.len() + 1); + let mut copy = alloc::vec::Vec::with_capacity(data.len() + 1); copy.extend_from_slice(data); copy.push(to_push); copy