libc: allocate more backing store in memory allocator

Add the size of the 'Dataspace' object and AVL-node slab blocks like in
the 'Genode::Heap' implementation.

Fixes #2925
This commit is contained in:
Christian Prochaska 2018-07-26 14:50:12 +02:00 committed by Christian Helmuth
parent 2ec48c32cb
commit 3a1c1d1fd5
1 changed files with 4 additions and 3 deletions

View File

@ -96,11 +96,12 @@ void *Libc::Mem_alloc_impl::alloc(size_t size, size_t align_log2)
/*
* Calculate block size of needed backing store. The block must hold the
* requested 'size' with the requested alignment and a new Dataspace
* structure if the allocation above failed.
* requested 'size' with the requested alignment, a new Dataspace structure
* and space for AVL-node slab blocks if the allocation above failed.
* Finally, we align the size to a 4K page.
*/
size_t request_size = size + max((1 << align_log2), 1024);
size_t request_size = size + max((1 << align_log2), 1024) +
Allocator_avl::slab_block_size() + sizeof(Dataspace);
if (request_size < _chunk_size*sizeof(umword_t)) {
request_size = _chunk_size*sizeof(umword_t);