mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-18 21:27:56 +00:00
util/string.h: Byte_range_ptr::with_skipped_bytes
The new method provides a safe way to narrow the byte range to a given offset. Issue #5351
This commit is contained in:
parent
5c20de212a
commit
bf064874db
@ -84,6 +84,15 @@ struct Genode::Byte_range_ptr : Noncopyable
|
||||
|
||||
Byte_range_ptr(char *start, size_t num_bytes)
|
||||
: start(start), num_bytes(num_bytes) { }
|
||||
|
||||
void with_skipped_bytes(size_t const n, auto const &fn)
|
||||
{
|
||||
if (num_bytes <= n)
|
||||
return;
|
||||
|
||||
Byte_range_ptr const remainder { start + n, num_bytes - n };
|
||||
fn(remainder);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user