Skip to content

Commit 985dbaf

Browse files
committed
align CPD API with the rest of the parsing using &[u8]
Signed-off-by: Daniel Maslowski <[email protected]>
1 parent ecceb8f commit 985dbaf

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/dir/gen3.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl Display for CodePartitionDirectory {
125125
}
126126

127127
impl CodePartitionDirectory {
128-
pub fn new(data: Vec<u8>, offset: usize, size: usize) -> Result<Self, String> {
128+
pub fn new(data: &[u8], offset: usize, size: usize) -> Result<Self, String> {
129129
let Ok((header, _)) = CPDHeader::read_from_prefix(&data) else {
130130
return Err("could not parse CPD header".to_string());
131131
};

src/me.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,7 @@ impl ME {
7777
if o + 4 < data.len() {
7878
let buf = &data[o..o + 4];
7979
if buf.eq(CPD_MAGIC_BYTES) {
80-
if let Ok(cpd) =
81-
CodePartitionDirectory::new(data[o..o + s].to_vec(), o, s)
80+
if let Ok(cpd) = CodePartitionDirectory::new(&data[o..o + s], o, s)
8281
{
8382
gen3dirs.push(cpd);
8483
}
@@ -156,7 +155,7 @@ impl ME {
156155
while o < data.len() {
157156
let buf = &data[o..o + 4];
158157
if buf.eq(CPD_MAGIC_BYTES) {
159-
let Ok(cpd) = CodePartitionDirectory::new(data[o..].to_vec(), o, 0) else {
158+
let Ok(cpd) = CodePartitionDirectory::new(&data[o..], o, 0) else {
160159
continue;
161160
};
162161
gen3dirs.push(cpd);

0 commit comments

Comments
 (0)