mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-07 23:38:00 +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() {
|
||||
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))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user