# SimpleAllocator

from pandac.PandaModules import SimpleAllocator

Class : SimpleAllocator
Description : An implementation of a very simple block allocator. This class can allocate ranges of nonnegative integers within a specified upper limit; it uses a simple first-fit algorithm to find the next available space.

## Inheritance:

SimpleAllocator: LinkedListNode
LinkedListNode:

## Methods of SimpleAllocator:

SimpleAllocator (Constructor)
alloc
getContiguous
getFirstBlock
getMaxSize
getTotalSize
isEmpty
output
setMaxSize
write

SimpleAllocator SimpleAllocator::SimpleAllocator(unsigned int max_size, Mutex &lock); Description:

alloc SimpleAllocatorBlock *SimpleAllocator::alloc(unsigned int size); Description: Allocates a new block. Returns NULL if a block of the requested size cannot be allocated. To free the allocated block, call block->free(), or simply delete the block pointer.

getContiguous unsigned int SimpleAllocator::get_contiguous(void) const; Description: Returns an upper-bound estimate of the size of the largest contiguous block that may be allocated. It is guaranteed that an attempt to allocate a block larger than this will fail, though it is not guaranteed that an attempt to allocate a block this size or smaller will succeed.

getFirstBlock SimpleAllocatorBlock *SimpleAllocator::get_first_block(void) const; Description: Returns a pointer to the first allocated block, or NULL if there are no allocated blocks.

getMaxSize unsigned int SimpleAllocator::get_max_size(void) const; Description: Returns the available space for allocated objects.

getTotalSize unsigned int SimpleAllocator::get_total_size(void) const; Description: Returns the total size of allocated objects.

isEmpty bool SimpleAllocator::is_empty(void) const; Description: Returns true if there are no blocks allocated on this page, or false if there is at least one.

output void SimpleAllocator::output(ostream &out) const; Description:

setMaxSize void SimpleAllocator::set_max_size(unsigned int max_size); Description: Changes the available space for allocated objects. This will not affect any already-allocated objects, but will have an effect on future calls to alloc().

write void SimpleAllocator::write(ostream &out) const; Description: