Skip to content

Commit b0bfd75

Browse files
removed table_name format!() allocation.
1 parent a266a31 commit b0bfd75

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

mythril/src/acpi/rsdt.rs

+8-3
Original file line numberDiff line numberDiff line change
@@ -371,16 +371,21 @@ impl<'a, T: Array<Item = u8>> RSDTBuilder<'a, T> {
371371
})?;
372372

373373
for (i, (name, (sdt, size))) in self.map.iter().enumerate() {
374-
let table_name = format!("etc/mythril/{}", str::from_utf8(name)?);
374+
const LEN_OF_ETC_MYTHRIL :usize = 12;
375+
const LEN_OF_NAME: usize = 4;
376+
let mut table_name_bytes = [0u8;LEN_OF_ETC_MYTHRIL + LEN_OF_NAME];
377+
table_name_bytes[0..LEN_OF_ETC_MYTHRIL].copy_from_slice("etc/mythril/".as_bytes());
378+
table_name_bytes[LEN_OF_ETC_MYTHRIL..].copy_from_slice(name);
379+
let table_name = str::from_utf8(&table_name_bytes)?;
375380

376381
table_loader.add_command(TableLoaderCommand::Allocate {
377-
file: &table_name,
382+
file: table_name,
378383
align: 8,
379384
zone: AllocZone::Fseg,
380385
})?;
381386

382387
table_loader.add_command(TableLoaderCommand::AddPointer {
383-
src: &table_name,
388+
src: table_name,
384389
dst: "etc/mythril/xsdt",
385390
offset: ((i * 8) + offsets::CREATOR_REVISION.end) as u32,
386391
size: 8,

0 commit comments

Comments
 (0)