mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-23 22:31:06 +00:00
Get rid of memcpy in to_vec() (#1512)
This commit is contained in:
committed by
Bastian Köcher
parent
9ae1316c86
commit
bcfb75b78e
@@ -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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user