Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# OsclMemPoolResizableAllocator Class Reference
[OSCL Memory]

`#include <oscl_mem_mempool.h>`

Inheritance diagram for OsclMemPoolResizableAllocator:

## Public Methods
OSCL_IMPORT_REF | OsclMemPoolResizableAllocator (uint32 aMemPoolBufferSize, uint32 aMemPoolBufferNumLimit=0, uint32 aExpectedNumBlocksPerBuffer=0, Oscl_DefAlloc *gen_alloc=NULL)
virtual OSCL_IMPORT_REF void | enablenullpointerreturn ()
virtual OSCL_IMPORT_REF OsclAny * | allocate (const uint32 aNumBytes)
virtual OSCL_IMPORT_REF void | deallocate (OsclAny *aPtr)
virtual OSCL_IMPORT_REF bool | trim (OsclAny *aPtr, uint32 aBytesToFree)
OSCL_IMPORT_REF uint32 | getBufferSize () const
virtual OSCL_IMPORT_REF uint32 | getAllocatedSize () const
virtual OSCL_IMPORT_REF uint32 | getAvailableSize () const
virtual OSCL_IMPORT_REF uint32 | getLargestContiguousFreeBlockSize () const
virtual OSCL_IMPORT_REF bool | setMaxSzForNewMemPoolBuffer (uint32 aMaxNewMemPoolBufferSz)
virtual OSCL_IMPORT_REF void | notifyfreeblockavailable (OsclMemPoolResizableAllocatorObserver &aObserver, uint32 aRequestedSize=0, OsclAny *aContextData=NULL)
virtual OSCL_IMPORT_REF void | CancelFreeChunkAvailableCallback ()
virtual OSCL_IMPORT_REF void | notifyfreememoryavailable (OsclMemPoolResizableAllocatorMemoryObserver &aObserver, uint32 aRequestedSize=0, OsclAny *aContextData=NULL)
OSCL_IMPORT_REF void | CancelFreeMemoryAvailableCallback ()
OSCL_IMPORT_REF void | addRef ()
OSCL_IMPORT_REF void | removeRef ()
## Protected Methods
virtual | ~OsclMemPoolResizableAllocator ()
MemPoolBufferInfo * | addnewmempoolbuffer (uint32 aBufferSize)
void | destroyallmempoolbuffers ()
MemPoolBlockInfo * | findfreeblock (uint32 aBlockSize)
OsclAny * | allocateblock (MemPoolBlockInfo &aBlockPtr, uint32 aNumBytes)
void | deallocateblock (MemPoolBlockInfo &aBlockPtr)
bool | validateblock (OsclAny *aBlockBufPtr)
uint32 | getMemPoolBufferSize (MemPoolBufferInfo *aBufferInfo) const
uint32 | getMemPoolBufferAllocatedSize (MemPoolBufferInfo *aBufferInfo) const
uint32 | memoryPoolBufferMgmtOverhead () const
## Protected Attributes
uint32 | iMemPoolBufferSize
uint32 | iMemPoolBufferNumLimit
uint32 | iExpectedNumBlocksPerBuffer
uint32 | iMaxNewMemPoolBufferSz
Oscl_DefAlloc * | iMemPoolBufferAllocator
Oscl_Vector< MemPoolBufferInfo *, OsclMemAllocator > | iMemPoolBufferList
uint32 | iBufferInfoAlignedSize
uint32 | iBlockInfoAlignedSize
bool | iCheckNextAvailable
uint32 | iRequestedNextAvailableSize
OsclAny * | iNextAvailableContextData
OsclMemPoolResizableAllocatorObserver * | iObserver
bool | iCheckFreeMemoryAvailable
uint32 | iRequestedAvailableFreeMemSize
OsclAny * | iFreeMemContextData
OsclMemPoolResizableAllocatorMemoryObserver * | iFreeMemPoolObserver
int32 | iRefCount
bool | iEnableNullPtrReturn

## Constructor & Destructor Documentation

OSCL_IMPORT_REF OsclMemPoolResizableAllocator::OsclMemPoolResizableAllocator | ( | uint32 | aMemPoolBufferSize,
|  | uint32 | aMemPoolBufferNumLimit = 0,
|  | uint32 | aExpectedNumBlocksPerBuffer = 0,
|  | Oscl_DefAlloc * | gen_alloc = NULL
| ) |

| Create the memory pool allocator with resizing functionality. The size of the memory pool buffer needs to be passed-in. The maximum number of memory pool buffers, expected number of blocks in a memory pool buffer, and outside allocator are optional. This API throws an exception when the memory allocation for the pool buffer fails. If memory pool buffer number limit parameter is not set, the assumption is that there is no limit and memory pool will grow as needed. If the expected number of blocks is not set or not known, the memory pool will use a default value to 10 to allocate extra memory for the block info header. Returns: void

virtual OsclMemPoolResizableAllocator::~OsclMemPoolResizableAllocator | ( |  | ) | `[inline, protected, virtual]`

| The destructor for the memory pool. Should not be called directly. Use removeRef() instead.

## Member Function Documentation

MemPoolBufferInfo* OsclMemPoolResizableAllocator::addnewmempoolbuffer | ( | uint32 | aBufferSize | ) | `[protected]`

OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::addRef | ( |  | ) |

| Increments the reference count for this memory pool allocator Returns: void

virtual OSCL_IMPORT_REF OsclAny* OsclMemPoolResizableAllocator::allocate | ( | const uint32 | aNumBytes | ) | `[virtual]`

| Allocates a block from the memory pool that is at least in size requested This API throws an exception if there isn't enough memory (if "enablenullpointerreturn" has not been called) for the requested amount in the pool or if the extra pool buffer cannot be allocated. Returns: Pointer to memory buffer from memory pool Implements Oscl_DefAlloc.

OsclAny* OsclMemPoolResizableAllocator::allocateblock | ( | MemPoolBlockInfo & | aBlockPtr,
|  | uint32 | aNumBytes
| ) | `[protected]`

virtual OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::CancelFreeChunkAvailableCallback | ( |  | ) | `[virtual]`

| This API will cancel any past callback requests.. Returns: void

OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::CancelFreeMemoryAvailableCallback | ( |  | ) |

virtual OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::deallocate | ( | OsclAny * | aPtr | ) | `[virtual]`

| Deallocates and returns a block back to the memory pool This API throws an exception if the pointer passed in is not part of the memory pool, aligned, or has corrupted block header. Returns: void Implements Oscl_DefAlloc.

void OsclMemPoolResizableAllocator::deallocateblock | ( | MemPoolBlockInfo & | aBlockPtr | ) | `[protected]`

void OsclMemPoolResizableAllocator::destroyallmempoolbuffers | ( |  | ) | `[protected]`

virtual OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::enablenullpointerreturn | ( |  | ) | `[virtual]`

| This API will disable exceptions in case the memory pool runs out of memory Instead of doing "OSCL_LEAVE(OsclErrNoResources)" allocate API will return NULL. Returns: void

MemPoolBlockInfo* OsclMemPoolResizableAllocator::findfreeblock | ( | uint32 | aBlockSize | ) | `[protected]`

virtual OSCL_IMPORT_REF uint32 OsclMemPoolResizableAllocator::getAllocatedSize | ( |  | ) | `[virtual]`

| Returns the number of bytes allocated from the buffer<including the overhead bytes that may be allocated by the allocater to keep track of the chunks allocated>

virtual OSCL_IMPORT_REF uint32 OsclMemPoolResizableAllocator::getAvailableSize | ( |  | ) | `[virtual]`

| Returns the number of bytes available with the buffer

OSCL_IMPORT_REF uint32 OsclMemPoolResizableAllocator::getBufferSize | ( |  | ) |

| Returns the size of the buffer <including the overhead bytes that may be allocated by the allocater>

virtual OSCL_IMPORT_REF uint32 OsclMemPoolResizableAllocator::getLargestContiguousFreeBlockSize | ( |  | ) | `[virtual]`

| Returns the size of the largest available chunk in the memory.

uint32 OsclMemPoolResizableAllocator::getMemPoolBufferAllocatedSize | ( | MemPoolBufferInfo * | aBufferInfo | ) | const`[protected]`

uint32 OsclMemPoolResizableAllocator::getMemPoolBufferSize | ( | MemPoolBufferInfo * | aBufferInfo | ) | const`[protected]`

uint32 OsclMemPoolResizableAllocator::memoryPoolBufferMgmtOverhead | ( |  | ) | `[protected]`

virtual OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::notifyfreeblockavailable | ( | OsclMemPoolResizableAllocatorObserver & | aObserver,
|  | uint32 | aRequestedSize = 0,
|  | OsclAny * | aContextData = NULL
| ) | `[virtual]`

| This API will set the flag to send a callback via specified observer object when the next memory block is deallocated by deallocate() call. If the optional requested size parameter is set, the callback is sent when a free memory space of requested size becomes available. The optional context data is returned with the callback and can be used by the user to differentiate.between different instances of memory pool objects. This memory pool only allows one notify to be queued. Another call to this function will just overwrite the previous call. Returns: void

virtual OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::notifyfreememoryavailable | ( | OsclMemPoolResizableAllocatorMemoryObserver & | aObserver,
|  | uint32 | aRequestedSize = 0,
|  | OsclAny * | aContextData = NULL
| ) | `[virtual]`

OSCL_IMPORT_REF void OsclMemPoolResizableAllocator::removeRef | ( |  | ) |

| Decrements the reference count for this memory pool allocator When the reference count goes to 0, this instance of the memory pool object is deleted Returns: void

virtual OSCL_IMPORT_REF bool OsclMemPoolResizableAllocator::setMaxSzForNewMemPoolBuffer | ( | uint32 | aMaxNewMemPoolBufferSz | ) | `[virtual]`

virtual OSCL_IMPORT_REF bool OsclMemPoolResizableAllocator::trim | ( | OsclAny * | aPtr,
|  | uint32 | aBytesToFree
| ) | `[virtual]`

| Returns a tail segment of a previously allocated memory block back to the memory pool. The passed-in pointer to the memory buffer is still valid after the call completes but the buffer size is smaller by by specified amount that was freed. This function allows the user to allocate a larger size block initially when the amount needed is unknown and then return the unused portion of the block when the amount becomes known. This API throws an exception if the pointer passed in is not part of the memory pool or the size to return is bigger than the size of the passed-in block. Exception will be thrown if the memory pool is not set up yet. Returns: bool True if trim operation successful. False if the block wasn't trimmed

bool OsclMemPoolResizableAllocator::validateblock | ( | OsclAny * | aBlockBufPtr | ) | `[protected]`

## Field Documentation

uint32 OsclMemPoolResizableAllocator::iBlockInfoAlignedSize`[protected]`

uint32 OsclMemPoolResizableAllocator::iBufferInfoAlignedSize`[protected]`

bool OsclMemPoolResizableAllocator::iCheckFreeMemoryAvailable`[protected]`

bool OsclMemPoolResizableAllocator::iCheckNextAvailable`[protected]`

bool OsclMemPoolResizableAllocator::iEnableNullPtrReturn`[protected]`

uint32 OsclMemPoolResizableAllocator::iExpectedNumBlocksPerBuffer`[protected]`

OsclAny* OsclMemPoolResizableAllocator::iFreeMemContextData`[protected]`

OsclMemPoolResizableAllocatorMemoryObserver* OsclMemPoolResizableAllocator::iFreeMemPoolObserver`[protected]`

uint32 OsclMemPoolResizableAllocator::iMaxNewMemPoolBufferSz`[protected]`

Oscl_DefAlloc* OsclMemPoolResizableAllocator::iMemPoolBufferAllocator`[protected]`

Oscl_Vector<MemPoolBufferInfo*, OsclMemAllocator> OsclMemPoolResizableAllocator::iMemPoolBufferList`[protected]`

uint32 OsclMemPoolResizableAllocator::iMemPoolBufferNumLimit`[protected]`

uint32 OsclMemPoolResizableAllocator::iMemPoolBufferSize`[protected]`

OsclAny* OsclMemPoolResizableAllocator::iNextAvailableContextData`[protected]`

OsclMemPoolResizableAllocatorObserver* OsclMemPoolResizableAllocator::iObserver`[protected]`

int32 OsclMemPoolResizableAllocator::iRefCount`[protected]`

uint32 OsclMemPoolResizableAllocator::iRequestedAvailableFreeMemSize`[protected]`

uint32 OsclMemPoolResizableAllocator::iRequestedNextAvailableSize`[protected]`

The documentation for this class was generated from the following file:

- oscl_mem_mempool.h