Panda3D
Public Member Functions | Friends | List of all members
SimpleAllocatorBlock Class Reference

A single block as returned from SimpleAllocator::alloc(). More...

#include "simpleAllocator.h"

Inheritance diagram for SimpleAllocatorBlock:
LinkedListNode VertexDataBlock VertexDataSaveBlock

Public Member Functions

 ~SimpleAllocatorBlock ()
 The block automatically frees itself when it destructs. More...
 
void free ()
 Releases the allocated space. More...
 
SimpleAllocatorget_allocator () const
 Returns the SimpleAllocator object that owns this block. More...
 
size_t get_max_size () const
 Returns the maximum size this block can be reallocated to, as limited by the following block. More...
 
SimpleAllocatorBlockget_next_block () const
 Returns a pointer to the next allocated block in the chain, or NULL if there are no more allocated blocks. More...
 
size_t get_size () const
 Returns the size of this block. More...
 
size_t get_start () const
 Returns the starting point of this block. More...
 
bool is_free () const
 Returns true if the block has been freed, false if it is still valid. More...
 
void output (ostream &out) const
 
bool realloc (size_t size)
 Changes the size of this block to the specified size. More...
 

Friends

class SimpleAllocator
 

Detailed Description

A single block as returned from SimpleAllocator::alloc().

Definition at line 95 of file simpleAllocator.h.

Constructor & Destructor Documentation

◆ ~SimpleAllocatorBlock()

SimpleAllocatorBlock::~SimpleAllocatorBlock ( )
inline

The block automatically frees itself when it destructs.

Definition at line 185 of file simpleAllocator.I.

References free().

Referenced by SimpleAllocator::get_first_block().

Member Function Documentation

◆ free()

void SimpleAllocatorBlock::free ( )
inline

Releases the allocated space.

Definition at line 195 of file simpleAllocator.I.

References get_allocator().

Referenced by ~SimpleAllocatorBlock().

◆ get_allocator()

SimpleAllocator * SimpleAllocatorBlock::get_allocator ( ) const
inline

Returns the SimpleAllocator object that owns this block.

Returns NULL if the block has been freed.

Definition at line 209 of file simpleAllocator.I.

References get_start().

Referenced by free(), and VertexDataBlock::get_page().

◆ get_max_size()

size_t SimpleAllocatorBlock::get_max_size ( ) const
inline

Returns the maximum size this block can be reallocated to, as limited by the following block.

Definition at line 255 of file simpleAllocator.I.

References realloc().

Referenced by is_free().

◆ get_next_block()

SimpleAllocatorBlock * SimpleAllocatorBlock::get_next_block ( ) const
inline

Returns a pointer to the next allocated block in the chain, or NULL if there are no more allocated blocks.

Definition at line 282 of file simpleAllocator.I.

Referenced by VertexDataBlock::get_next_block(), and realloc().

◆ get_size()

size_t SimpleAllocatorBlock::get_size ( ) const
inline

Returns the size of this block.

It is an error to call this if the block has been freed.

Definition at line 232 of file simpleAllocator.I.

References is_free().

Referenced by get_start(), and VertexDataSaveFile::read_data().

◆ get_start()

size_t SimpleAllocatorBlock::get_start ( ) const
inline

Returns the starting point of this block.

It is an error to call this if the block has been freed.

Definition at line 220 of file simpleAllocator.I.

References get_size().

Referenced by get_allocator(), VertexDataBlock::get_pointer(), and VertexDataSaveFile::read_data().

◆ is_free()

bool SimpleAllocatorBlock::is_free ( ) const
inline

Returns true if the block has been freed, false if it is still valid.

Definition at line 244 of file simpleAllocator.I.

References get_max_size().

Referenced by get_size().

◆ realloc()

bool SimpleAllocatorBlock::realloc ( size_t  size)
inline

Changes the size of this block to the specified size.

Returns true if the change is accepted, false if there was not enough room.

Definition at line 269 of file simpleAllocator.I.

References get_next_block().

Referenced by get_max_size().


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