mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 15:32:25 +00:00
base: Add Allocator_avl::size_at function
This function provides a way to request the size of an previously allocated block. It is useful to to ease the implementation of realloc functionality based on Allocator_avl.
This commit is contained in:
parent
16bc2bc840
commit
db2fe17269
@ -231,6 +231,11 @@ namespace Genode {
|
||||
|
||||
void free(void *addr, size_t) { free(addr); }
|
||||
|
||||
/**
|
||||
* Return size of block at specified address
|
||||
*/
|
||||
size_t size_at(void const *addr) const;
|
||||
|
||||
/**
|
||||
* Return the memory overhead per Block
|
||||
*
|
||||
|
@ -339,6 +339,15 @@ void Allocator_avl_base::free(void *addr)
|
||||
}
|
||||
|
||||
|
||||
size_t Allocator_avl_base::size_at(void const *addr) const
|
||||
{
|
||||
/* lookup corresponding block */
|
||||
Block *b = _find_by_address(reinterpret_cast<addr_t>(addr));
|
||||
|
||||
return (b && b->used()) ? b->size() : 0;
|
||||
}
|
||||
|
||||
|
||||
bool Allocator_avl_base::any_block_addr(addr_t *out_addr)
|
||||
{
|
||||
Block *b = _addr_tree.first();
|
||||
|
Loading…
Reference in New Issue
Block a user