Get rid of memcpy in to_vec() (#1512)

This commit is contained in:
Michael Müller
2019-01-22 09:45:03 +01:00
committed by Bastian Köcher
parent 9ae1316c86
commit bcfb75b78e
+4 -3
View File
@@ -283,9 +283,10 @@ pub fn child_storage_root(storage_key: &[u8]) -> Option<Vec<u8>> {
if length == u32::max_value() { if length == u32::max_value() {
None None
} else { } else {
let ret = slice::from_raw_parts(ptr, length as usize).to_vec(); // Invariants required by Vec::from_raw_parts are not formally fulfilled.
ext_free(ptr); // We don't allocate via String/Vec<T>, but use a custom allocator instead.
Some(ret) // See #300 for more details.
Some(<Vec<u8>>::from_raw_parts(ptr, length as usize, length as usize))
} }
} }
} }