SimpleAllocator

class SimpleAllocator

Bases: LinkedListNode

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 diagram

digraph inheritance3575184b86 { bgcolor=transparent; rankdir=BT; size="8.0, 12.0"; "DTOOL_SUPER_BASE" [fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style=""]; "SimpleAllocator" [URL="acron.core.SimpleAllocator.html#acron.core.SimpleAllocator",fillcolor=white,fontname="Vera Sans, DejaVu Sans, Liberation Sans, Arial, Helvetica, sans",fontsize=11,height=0.25,shape=box,style="",target="_top",tooltip="/**"]; "DTOOL_SUPER_BASE" -> "SimpleAllocator" [arrowsize=0.75,style=""]; }
SimpleAllocator.__init__()

Move constructor.

SimpleAllocator.alloc()

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.

SimpleAllocator.get_contiguous()

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.

SimpleAllocator.get_first_block()

Returns a pointer to the first allocated block, or NULL if there are no allocated blocks.

SimpleAllocator.get_max_size()

Returns the available space for allocated objects.

SimpleAllocator.get_total_size()

Returns the total size of allocated objects.

SimpleAllocator.is_empty()

Returns true if there are no blocks allocated on this page, or false if there is at least one.

SimpleAllocator.output()
SimpleAllocator.set_max_size()

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().

SimpleAllocator.write()