mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2026-08-05 02:19:16 +00:00
virtio-devices: avoid creating a temporary vector
... by passing the slice along instead. On-behalf-of: SAP julian.stecklina@sap.com Signed-off-by: Julian Stecklina <julian.stecklina@cyberus-technology.de>
This commit is contained in:
committed by
Rob Bradford
parent
3d5f9a3a98
commit
fc99e299c3
@@ -570,12 +570,16 @@ impl VhostUserHandle {
|
||||
// divide it by 8.
|
||||
let len = region.size() / 8;
|
||||
// SAFETY: region is of size len
|
||||
let bitmap = unsafe {
|
||||
let bitmap: &[u64] = unsafe {
|
||||
// Cast the pointer to u64
|
||||
let ptr = region.as_ptr() as *const u64;
|
||||
std::slice::from_raw_parts(ptr, len).to_vec()
|
||||
std::slice::from_raw_parts(ptr, len)
|
||||
};
|
||||
Ok(MemoryRangeTable::from_bitmap(bitmap, 0, 4096))
|
||||
Ok(MemoryRangeTable::from_bitmap(
|
||||
bitmap.iter().copied(),
|
||||
0,
|
||||
4096,
|
||||
))
|
||||
} else {
|
||||
Err(Error::MissingShmLogRegion)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user