(buf: &[u8])
| 441 | } |
| 442 | |
| 443 | fn get_ref_from_buffer<T>(buf: &[u8]) -> Result<&T, ParsingError> { |
| 444 | if buf.len() < size_of::<T>() { |
| 445 | return Err(ParsingError::BufferTooSmall); |
| 446 | } |
| 447 | |
| 448 | if (buf.as_ptr() as usize) % std::mem::align_of::<T>() != 0 { |
| 449 | return Err(ParsingError::BadAlignment); |
| 450 | } |
| 451 | |
| 452 | Ok(unsafe { &*(buf.as_ptr() as *const T) }) |
| 453 | } |
| 454 | |
| 455 | fn get_dump_headers_from_buffer(buf: &[u8]) -> Result<&DUMP_HEADER64, ParsingError> { |
| 456 | let headers: &DUMP_HEADER64 = get_ref_from_buffer(buf)?; |
no outgoing calls
no test coverage detected