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:
Josef Söntgen 2013-03-06 13:01:26 +01:00 committed by Norman Feske
parent 0ba40d01ca
commit 9ec791db9a
1 changed files with 11 additions and 0 deletions

View File

@ -43,6 +43,17 @@ namespace Genode {
void upgrade(size_t 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 **