18#ifndef __LIBALLOC_POOLALLOCATOR_H
19#define __LIBALLOC_POOLALLOCATOR_H
64 const Size objectSize,
Allocator * parent()
Get parent Allocator.
Result
Allocation results.
Memory allocator which uses pools that each manage same-sized objects.
static const Size MaximumPoolSize
Maximum power of two size a pool can be (128MiB).
Size calculateObjectCount(const Size objectSize) const
Calculate minimum object count for a Pool.
static const Size MinimumPoolSize
Minimum power of two for a pool size.
Pool * m_pools[MaximumPoolSize+1]
Array of memory pools.
virtual Result allocate(Range &args)
Allocate memory.
Size calculateObjectSize(const Size index) const
Calculate object size given the Pool index number.
virtual Size size() const
Get memory size.
void calculateUsage(Size &totalSize, Size &totalUsed) const
Determine total memory usage.
static const u32 ObjectSignature
Signature value is used to detect object corruption/overflows.
virtual Size available() const
Get memory available.
Pool * retrievePool(const Size inputSize)
Find a Pool of sufficient size.
Result releasePool(Pool *pool)
Release Pool instance memory.
Pool * allocatePool(const uint index, const Size objectCount)
Creates a new Pool instance.
virtual Result release(const Address addr)
Release memory.
unsigned int u32
Unsigned 32-bit number.
unsigned long Address
A memory address.
unsigned int uint
Unsigned integer number.
unsigned int Size
Any sane size indicator cannot go negative.
unsigned char u8
Unsigned 8-bit number.
Describes a range of memory.
Appended in memory after each object.
u32 signature
Filled with a fixed value to detect corruption/overflows.
This data structure is prepended in memory before each object.
Pool * pool
Points to the Pool instance where this object belongs to.
u32 signature
Filled with a fixed value to detect corruption/overflows.
Allocates same-sized objects from a contiguous block of memory.
Pool * next
Points to the next pool of this size (if any).
Pool * prev
Points to the previous pool of this size (if any).
Pool(const Range &range, const Size objectSize, const Size bitmapSize, u8 *bitmap)
Size index
Index number in the m_pools array where this Pool is stored.
const Size bitmapSize
Size in bytes of the bitmap array.