Skip to content

Commit

Permalink
Fix usage of Global.alloc
Browse files Browse the repository at this point in the history
  • Loading branch information
faern committed Apr 5, 2020
1 parent a2d606f commit 6cceae6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vec-final.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use std::ptr::{Unique, NonNull, self};
use std::mem;
use std::ops::{Deref, DerefMut};
use std::marker::PhantomData;
use std::alloc::{AllocRef, GlobalAlloc, Layout, Global, handle_alloc_error};
use std::alloc::{AllocInit, AllocRef, GlobalAlloc, Layout, Global, handle_alloc_error};

struct RawVec<T> {
ptr: Unique<T>,
Expand All @@ -34,7 +34,7 @@ impl<T> RawVec<T> {
assert!(elem_size != 0, "capacity overflow");

let (new_cap, ptr) = if self.cap == 0 {
let ptr = Global.alloc(Layout::array::<T>(1).unwrap());
let ptr = Global.alloc(Layout::array::<T>(1).unwrap(), AllocInit::Uninitialized);
(1, ptr)
} else {
let new_cap = 2 * self.cap;
Expand Down

0 comments on commit 6cceae6

Please sign in to comment.