mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-18 21:27:56 +00:00
base: Attached_dataspace::bytes accessor
The new bytes() accessor returns a Byte_range_pointer as an alternative to the 'local_addr' for accessing the content of the dataspace. This facilitates the safe practice of passing (and validating) the buffer bounds along with the pointer. Issue #5351
This commit is contained in:
parent
e738162bde
commit
5c20de212a
@ -54,12 +54,6 @@ class Genode::Attached_dataspace : Noncopyable
|
||||
[&] (Region_map::Attach_error) { return nullptr; });
|
||||
}
|
||||
|
||||
/*
|
||||
* Noncopyable
|
||||
*/
|
||||
Attached_dataspace(Attached_dataspace const &);
|
||||
Attached_dataspace &operator = (Attached_dataspace const &);
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
@ -118,6 +112,11 @@ class Genode::Attached_dataspace : Noncopyable
|
||||
[&] (Region_map::Attach_error) { return 0UL; });
|
||||
}
|
||||
|
||||
/**
|
||||
* Return byte range of locally mapped dataspace
|
||||
*/
|
||||
Byte_range_ptr bytes() const { return { _ptr<char>(), size() }; }
|
||||
|
||||
/**
|
||||
* Forget dataspace, thereby skipping the detachment on destruction
|
||||
*
|
||||
|
@ -163,6 +163,11 @@ class Genode::Attached_ram_dataspace
|
||||
|
||||
_alloc_and_attach();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return byte range of locally mapped dataspace
|
||||
*/
|
||||
Byte_range_ptr bytes() const { return { local_addr<char>(), size() }; }
|
||||
};
|
||||
|
||||
#endif /* _INCLUDE__BASE__ATTACHED_RAM_DATASPACE_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user