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

This template class can be used to provide faster allocation/deallocation for many Panda objects. More...

#include "deletedBufferChain.h"

Public Member Functions

void * allocate (size_t size, TypeHandle type_handle)
 Allocates the memory for a new buffer of the indicated size (which must be no greater than the fixed size associated with the DeletedBufferChain). More...
 
void deallocate (void *ptr, TypeHandle type_handle)
 Frees the memory for a buffer previously allocated via allocate(). More...
 
size_t get_buffer_size () const
 Returns the size of the buffer that is actually returned at each request. More...
 
bool validate (void *ptr)
 Returns true if the pointer is valid, false if it has been deleted or if it was never a valid pointer. More...
 

Friends

class MemoryHook
 

Detailed Description

This template class can be used to provide faster allocation/deallocation for many Panda objects.

It works by maintaining a linked list of deleted buffers that are all of the same size; when a new object is allocated that matches that size, the same space is just reused.

This class manages untyped buffers of a fixed size. It can be used directly; or it also serves as a backbone for DeletedChain, which is a template class that manages object allocations.

Use MemoryHook to get a new DeletedBufferChain of a particular size.

Definition at line 58 of file deletedBufferChain.h.

Member Function Documentation

◆ allocate()

void * DeletedBufferChain::allocate ( size_t  size,
TypeHandle  type_handle 
)

Allocates the memory for a new buffer of the indicated size (which must be no greater than the fixed size associated with the DeletedBufferChain).

Definition at line 35 of file deletedBufferChain.cxx.

◆ deallocate()

void DeletedBufferChain::deallocate ( void *  ptr,
TypeHandle  type_handle 
)

Frees the memory for a buffer previously allocated via allocate().

Definition at line 102 of file deletedBufferChain.cxx.

◆ get_buffer_size()

size_t DeletedBufferChain::get_buffer_size ( ) const
inline

Returns the size of the buffer that is actually returned at each request.

Definition at line 40 of file deletedBufferChain.I.

◆ validate()

bool DeletedBufferChain::validate ( void *  ptr)
inline

Returns true if the pointer is valid, false if it has been deleted or if it was never a valid pointer.

This is only meaningful in debug mode, where USE_DELETEDCHAINFLAG is defined. If not, this trivially returns true.

Definition at line 22 of file deletedBufferChain.I.


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