Skip to content
Snippets Groups Projects
Commit bcfb75b7 authored by Michael Müller's avatar Michael Müller Committed by Bastian Köcher
Browse files

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

parent 9ae1316c
No related merge requests found
......@@ -283,9 +283,10 @@ pub fn child_storage_root(storage_key: &[u8]) -> Option<Vec<u8>> {
if length == u32::max_value() {
None
} else {
let ret = slice::from_raw_parts(ptr, length as usize).to_vec();
ext_free(ptr);
Some(ret)
// Invariants required by Vec::from_raw_parts are not formally fulfilled.
// We don't allocate via String/Vec<T>, but use a custom allocator instead.
// See #300 for more details.
Some(<Vec<u8>>::from_raw_parts(ptr, length as usize, length as usize))
}
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment