39 INLINE Type *allocate(
size_t size,
TypeHandle type_handle);
40 INLINE
void deallocate(Type *ptr,
TypeHandle type_handle);
42 INLINE
bool validate(
const Type *ptr);
48 INLINE
void init_deleted_chain();
68 INLINE
static Type *allocate(
size_t size,
TypeHandle type_handle);
69 INLINE
static void deallocate(Type *ptr,
TypeHandle type_handle);
71 INLINE
static bool validate(
const Type *ptr);
76#ifdef USE_DELETED_CHAIN
79#define ALLOC_DELETED_CHAIN(Type) \
80 inline void *operator new(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT) { \
81 return (void *)StaticDeletedChain< Type >::allocate(size, get_type_handle(Type)); \
83 inline void *operator new(size_t size, void *ptr) { \
87 inline void operator delete(void *ptr) { \
88 if (ptr != nullptr) { \
89 StaticDeletedChain< Type >::deallocate((Type *)ptr, get_type_handle(Type)); \
92 inline void operator delete(void *, void *) { \
94 inline static bool validate_ptr(const void *ptr) { \
95 return StaticDeletedChain< Type >::validate((const Type *)ptr); \
100#define ALLOC_DELETED_CHAIN_DECL(Type) \
101 inline void *operator new(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT) { \
102 return (void *)_deleted_chain.allocate(size, get_type_handle(Type)); \
104 inline void *operator new(size_t size, void *ptr) { \
108 inline void operator delete(void *ptr) { \
109 if (ptr != nullptr) { \
110 _deleted_chain.deallocate((Type *)ptr, get_type_handle(Type)); \
113 inline void operator delete(void *, void *) { \
115 inline static bool validate_ptr(const void *ptr) { \
116 return _deleted_chain.validate((const Type *)ptr); \
118 static DeletedChain< Type > _deleted_chain;
122#define ALLOC_DELETED_CHAIN_DEF(Type) \
123 DeletedChain< Type > Type::_deleted_chain;
127#define ALLOC_DELETED_CHAIN(Type) \
128 inline static bool validate_ptr(const void *ptr) { \
129 return (ptr != nullptr); \
131#define ALLOC_DELETED_CHAIN_DECL(Type) \
132 inline static bool validate_ptr(const void *ptr) { \
133 return (ptr != nullptr); \
135#define ALLOC_DELETED_CHAIN_DEF(Type)
139#include "deletedChain.T"
This template class can be used to provide faster allocation/deallocation for many Panda objects.
This template class can be used to provide faster allocation/deallocation for many Panda objects.
A base class for all things that want to be reference-counted.
This template class is used to conveniently declare a single instance of the DeletedChain template ob...
TypeHandle is the identifier used to differentiate C++ class types.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.