fix sized deallocation for OwnedSlice

This commit is contained in:
Daniel Micay 2014-09-05 06:19:15 -04:00
parent d1bd139251
commit 2fdad65a05

View File

@ -58,9 +58,12 @@ pub fn from_vec(mut v: Vec<T>) -> OwnedSlice<T> {
if len == 0 {
OwnedSlice::empty()
} else {
// drop excess capacity to avoid breaking sized deallocation
v.shrink_to_fit();
let p = v.as_mut_ptr();
// we own the allocation now
unsafe {mem::forget(v)}
unsafe { mem::forget(v) }
OwnedSlice { data: p, len: len }
}