mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-11 15:33:04 +00:00
libc: Add Libc::Mem_alloc::size_at
Adding this function eases the implementation of realloc based on 'Libc::Mem_alloc'. Note that this allocator is not used by libc's default malloc implementation but it is useful for customized C runtimes, e.g., for the runtime of VirtualBox.
This commit is contained in:
parent
db2fe17269
commit
75366c66a4
@ -88,7 +88,7 @@ namespace Libc {
|
|||||||
_ram_session = ram, _rm_session = rm; }
|
_ram_session = ram, _rm_session = rm; }
|
||||||
};
|
};
|
||||||
|
|
||||||
Lock _lock;
|
Lock mutable _lock;
|
||||||
Dataspace_pool _ds_pool; /* list of dataspaces */
|
Dataspace_pool _ds_pool; /* list of dataspaces */
|
||||||
Allocator_avl _alloc; /* local allocator */
|
Allocator_avl _alloc; /* local allocator */
|
||||||
size_t _chunk_size;
|
size_t _chunk_size;
|
||||||
@ -114,6 +114,7 @@ namespace Libc {
|
|||||||
|
|
||||||
void *alloc(Genode::size_t size, Genode::size_t align_log2);
|
void *alloc(Genode::size_t size, Genode::size_t align_log2);
|
||||||
void free(void *ptr);
|
void free(void *ptr);
|
||||||
|
Genode::size_t size_at(void const *ptr) const;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,6 +224,16 @@ void Libc::Mem_alloc_impl::free(void *addr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Genode::size_t Libc::Mem_alloc_impl::size_at(void const *addr) const
|
||||||
|
{
|
||||||
|
/* serialize access of heap functions */
|
||||||
|
Lock::Guard lock_guard(_lock);
|
||||||
|
|
||||||
|
/* forward request to our local allocator */
|
||||||
|
return _alloc.size_at(addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
Libc::Mem_alloc *Libc::mem_alloc()
|
Libc::Mem_alloc *Libc::mem_alloc()
|
||||||
{
|
{
|
||||||
static Libc::Mem_alloc_impl inst;
|
static Libc::Mem_alloc_impl inst;
|
||||||
|
@ -16,6 +16,7 @@ namespace Libc {
|
|||||||
{
|
{
|
||||||
virtual void *alloc(Genode::size_t size, Genode::size_t align_log2) = 0;
|
virtual void *alloc(Genode::size_t size, Genode::size_t align_log2) = 0;
|
||||||
virtual void free(void *ptr) = 0;
|
virtual void free(void *ptr) = 0;
|
||||||
|
virtual Genode::size_t size_at(void const *ptr) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user