Skip to content

Commit

Permalink
alloc_zeroed
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 authored and Licenser committed Jul 27, 2023
1 parent bc91877 commit a66d8fb
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ mod known_key;
pub use known_key::{Error as KnownKeyError, KnownKey};

pub use crate::tape::{Node, Tape};
use std::alloc::{alloc, handle_alloc_error, Layout};
use std::alloc::{alloc_zeroed, handle_alloc_error, Layout};
use std::ops::{Deref, DerefMut};
use std::ptr::NonNull;

Expand Down Expand Up @@ -489,8 +489,8 @@ impl<'de> Deserializer<'de> {

// ensure we have a 0 to terminate the buffer
std::ptr::write(input_buffer.as_mut_ptr().add(len), 0);
// safety: we just initialized all bytes up until `len`
input_buffer.set_len(len);

input_buffer.set_len(input_buffer.capacity());
};

let s1_result: std::result::Result<Vec<u32>, ErrorType> =
Expand Down Expand Up @@ -710,7 +710,7 @@ impl AlignedBuf {
if mem::size_of::<usize>() < 8 && capacity > isize::MAX as usize {
Self::capacity_overflow()
}
let inner = match unsafe { NonNull::new(alloc(layout)) } {
let inner = match unsafe { NonNull::new(alloc_zeroed(layout)) } {
Some(ptr) => ptr,
None => handle_alloc_error(layout),
};
Expand Down

0 comments on commit a66d8fb

Please sign in to comment.