Skip to content

Commit 6cceae6

Browse files
committed
Fix usage of Global.alloc
1 parent a2d606f commit 6cceae6

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/vec-final.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use std::ptr::{Unique, NonNull, self};
99
use std::mem;
1010
use std::ops::{Deref, DerefMut};
1111
use std::marker::PhantomData;
12-
use std::alloc::{AllocRef, GlobalAlloc, Layout, Global, handle_alloc_error};
12+
use std::alloc::{AllocInit, AllocRef, GlobalAlloc, Layout, Global, handle_alloc_error};
1313

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

3636
let (new_cap, ptr) = if self.cap == 0 {
37-
let ptr = Global.alloc(Layout::array::<T>(1).unwrap());
37+
let ptr = Global.alloc(Layout::array::<T>(1).unwrap(), AllocInit::Uninitialized);
3838
(1, ptr)
3939
} else {
4040
let new_cap = 2 * self.cap;

0 commit comments

Comments
 (0)