Panda3D
|
A single block as returned from SimpleAllocator::alloc(). More...
#include "simpleAllocator.h"
Public Member Functions | |
~SimpleAllocatorBlock () | |
The block automatically frees itself when it destructs. | |
void | free () |
Releases the allocated space. | |
SimpleAllocator * | get_allocator () const |
Returns the SimpleAllocator object that owns this block. | |
size_t | get_max_size () const |
Returns the maximum size this block can be reallocated to, as limited by the following block. | |
SimpleAllocatorBlock * | get_next_block () const |
Returns a pointer to the next allocated block in the chain, or NULL if there are no more allocated blocks. | |
size_t | get_size () const |
Returns the size of this block. | |
size_t | get_start () const |
Returns the starting point of this block. | |
bool | is_free () const |
Returns true if the block has been freed, false if it is still valid. | |
void | output (ostream &out) const |
bool | realloc (size_t size) |
Changes the size of this block to the specified size. | |
Protected Member Functions | |
SimpleAllocatorBlock (SimpleAllocator *alloc, size_t start, size_t size) | |
A SimpleAllocatorBlock must be constructed via the SimpleAllocator::alloc() call. | |
void | do_free () |
Releases the allocated space. | |
size_t | do_get_max_size () const |
Returns the maximum size this block can be reallocated to, as limited by the following block. | |
bool | do_realloc (size_t size) |
Changes the size of this block to the specified size. | |
void | insert_after (LinkedListNode *node) |
Adds a LinkedListNode record after the indicated node in the doubly-linked list. | |
void | insert_before (LinkedListNode *node) |
Adds a LinkedListNode record before the indicated node in the doubly-linked list. | |
bool | is_on_list () const |
Returns true if the node is member of any list, false if it has been removed or never added. | |
void | remove_from_list () |
Removes a LinkedListNode record from the doubly-linked list. | |
void | take_list_from (LinkedListNode *other_root) |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list. | |
Protected Attributes | |
LinkedListNode * | _next |
LinkedListNode * | _prev |
Friends | |
class | SimpleAllocator |
A single block as returned from SimpleAllocator::alloc().
Definition at line 95 of file simpleAllocator.h.
SimpleAllocatorBlock::SimpleAllocatorBlock | ( | SimpleAllocator * | alloc, |
size_t | start, | ||
size_t | size | ||
) | [inline, protected] |
A SimpleAllocatorBlock must be constructed via the SimpleAllocator::alloc() call.
Definition at line 170 of file simpleAllocator.I.
SimpleAllocatorBlock::~SimpleAllocatorBlock | ( | ) | [inline] |
The block automatically frees itself when it destructs.
Definition at line 185 of file simpleAllocator.I.
References free().
void SimpleAllocatorBlock::do_free | ( | ) | [inline, protected] |
Releases the allocated space.
Assumes the lock is already held.
Definition at line 296 of file simpleAllocator.I.
References SimpleAllocator::mark_contiguous(), and LinkedListNode::remove_from_list().
Referenced by free().
size_t SimpleAllocatorBlock::do_get_max_size | ( | ) | const [inline, protected] |
Returns the maximum size this block can be reallocated to, as limited by the following block.
Assumes the lock is already held.
Definition at line 315 of file simpleAllocator.I.
Referenced by do_realloc(), and get_max_size().
bool SimpleAllocatorBlock::do_realloc | ( | size_t | size | ) | [inline, protected] |
Changes the size of this block to the specified size.
Returns true if the change is accepted, false if there was not enough room.
Assumes the lock is already held.
Definition at line 335 of file simpleAllocator.I.
References do_get_max_size(), and SimpleAllocator::mark_contiguous().
Referenced by realloc().
void SimpleAllocatorBlock::free | ( | ) | [inline] |
Releases the allocated space.
Definition at line 195 of file simpleAllocator.I.
References do_free().
Referenced by ~SimpleAllocatorBlock().
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.
Referenced by SimpleAllocator::do_alloc(), and VertexDataBlock::get_page().
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 do_get_max_size().
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.
Reimplemented in VertexDataBlock.
Definition at line 282 of file simpleAllocator.I.
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.
Referenced by VertexDataSaveFile::read_data().
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.
Referenced by VertexDataBlock::get_pointer(), and VertexDataSaveFile::read_data().
void LinkedListNode::insert_after | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record after the indicated node in the doubly-linked list.
Definition at line 108 of file linkedListNode.I.
void LinkedListNode::insert_before | ( | LinkedListNode * | node | ) | [inline, protected, inherited] |
Adds a LinkedListNode record before the indicated node in the doubly-linked list.
Definition at line 91 of file linkedListNode.I.
Referenced by SimpleAllocator::do_alloc(), AdaptiveLru::do_partial_lru_update(), and SimpleLruPage::enqueue_lru().
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.
bool LinkedListNode::is_on_list | ( | ) | const [inline, protected, inherited] |
Returns true if the node is member of any list, false if it has been removed or never added.
The head of a list generally appears to to always be a member of itself.
Definition at line 62 of file linkedListNode.I.
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 do_realloc().
void LinkedListNode::remove_from_list | ( | ) | [inline, protected, inherited] |
Removes a LinkedListNode record from the doubly-linked list.
Definition at line 73 of file linkedListNode.I.
Referenced by SimpleLruPage::dequeue_lru(), do_free(), AdaptiveLru::do_partial_lru_update(), and SimpleLruPage::enqueue_lru().
void LinkedListNode::take_list_from | ( | LinkedListNode * | other_root | ) | [inline, protected, inherited] |
Given that this LinkedListNode represents the root of a list, and the other pointer represents the root of a different list, move all of the nodes (except the root itself) from other_root onto this list.
Definition at line 127 of file linkedListNode.I.
Referenced by BufferContextChain::take_from().