base: add method to withdraw memory w/o allocating
The given number of bytes is consumed but not actually allocated. This feature may be used for accounting and use memory within core which is in fact provided by a session client. Fixes #792.
This commit is contained in:
parent
0ba40d01ca
commit
9ec791db9a
|
@ -43,6 +43,17 @@ namespace Genode {
|
||||||
void upgrade(size_t additional_amount) {
|
void upgrade(size_t additional_amount) {
|
||||||
_amount += additional_amount; }
|
_amount += additional_amount; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Consume bytes without actually allocating them
|
||||||
|
*/
|
||||||
|
bool withdraw(size_t size)
|
||||||
|
{
|
||||||
|
if ((_amount - _consumed) < size)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
_consumed += size;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/*************************
|
/*************************
|
||||||
** Allocator interface **
|
** Allocator interface **
|
||||||
|
|
Loading…
Reference in New Issue
Block a user