mirror of
https://github.com/cloud-hypervisor/cloud-hypervisor.git
synced 2024-12-22 21:55:20 +00:00
acpi_tables: sdt: Add ability to add to the table from a slice
The generic version does not work in this case as it the size of the the &[u8] is not the size of the slice's contents but how much memory the slice object itself takes up. Signed-off-by: Rob Bradford <robert.bradford@intel.com>
This commit is contained in:
parent
c76fd6df21
commit
dd539df633
@ -77,6 +77,14 @@ impl SDT {
|
||||
self.write(orig_length, value);
|
||||
}
|
||||
|
||||
pub fn append_slice(&mut self, data: &[u8]) {
|
||||
let orig_length = self.data.len();
|
||||
let new_length = orig_length + data.len();
|
||||
self.write_u32(4, new_length as u32);
|
||||
self.data.extend_from_slice(data);
|
||||
self.update_checksum();
|
||||
}
|
||||
|
||||
/// Write a value at the given offset
|
||||
pub fn write<T>(&mut self, offset: usize, value: T) {
|
||||
assert!((offset + (std::mem::size_of::<T>() - 1)) < self.data.len());
|
||||
|
Loading…
Reference in New Issue
Block a user