panda3d.core.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

Inheritance diagram of SimpleAllocator

__init__(from: SimpleAllocator) → None

Move constructor.

__init__(max_size: size_t, lock: Mutex) → None
alloc(size: size_t, alignment: size_t) → SimpleAllocatorBlock

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.

Return type

SimpleAllocatorBlock

isEmpty() → bool

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

getTotalSize() → size_t

Returns the total size of allocated objects.

Return type

size_t

getMaxSize() → size_t

Returns the available space for allocated objects.

Return type

size_t

setMaxSize(max_size: size_t) → None

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

getContiguous() → size_t

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.

Return type

size_t

getFirstBlock() → SimpleAllocatorBlock

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

Return type

SimpleAllocatorBlock

output(out: ostream) → None
write(out: ostream) → None