File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed
Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -21,16 +21,24 @@ class MappedROM {
2121 size_t offset { 0 };
2222 PhysicalAddress paddr;
2323
24- Optional<PhysicalAddress> find_chunk_starting_with (StringView prefix, size_t chunk_size) const
24+ u8 const * pointer_to_chunk_starting_with (StringView prefix, size_t chunk_size) const
2525 {
2626 auto prefix_length = prefix.length ();
2727 if (size < prefix_length)
28- return {} ;
28+ return nullptr ;
2929 for (auto * candidate = base (); candidate <= end () - prefix_length; candidate += chunk_size) {
3030 if (!__builtin_memcmp (prefix.characters_without_null_termination (), candidate, prefix.length ()))
31- return paddr_of ( candidate) ;
31+ return candidate;
3232 }
33- return {};
33+ return nullptr ;
34+ }
35+
36+ Optional<PhysicalAddress> find_chunk_starting_with (StringView prefix, size_t chunk_size) const
37+ {
38+ auto result = pointer_to_chunk_starting_with (prefix, chunk_size);
39+ if (!result)
40+ return {};
41+ return paddr_of (result);
3442 }
3543
3644 PhysicalAddress paddr_of (u8 const * ptr) const { return paddr.offset (ptr - this ->base ()); }
You can’t perform that action at this time.
0 commit comments