15 #ifndef DELETEDCHAIN_H
16 #define DELETEDCHAIN_H
18 #include "dtoolbase.h"
19 #include "deletedBufferChain.h"
48 INLINE Type *allocate(
size_t size,
TypeHandle type_handle);
49 INLINE
void deallocate(Type *ptr,
TypeHandle type_handle);
51 INLINE
bool validate(
const Type *ptr);
57 INLINE
void init_deleted_chain();
82 INLINE
static Type *allocate(
size_t size,
TypeHandle type_handle);
83 INLINE
static void deallocate(Type *ptr,
TypeHandle type_handle);
85 INLINE
static bool validate(
const Type *ptr);
90 #ifdef USE_DELETED_CHAIN
94 #define ALLOC_DELETED_CHAIN(Type) \
95 inline void *operator new(size_t size) { \
96 return (void *)StaticDeletedChain< Type >::allocate(size, get_type_handle(Type)); \
98 inline void *operator new(size_t size, void *ptr) { \
102 inline void operator delete(void *ptr) { \
103 StaticDeletedChain< Type >::deallocate((Type *)ptr, get_type_handle(Type)); \
105 inline void operator delete(void *, void *) { \
107 inline static bool validate_ptr(const void *ptr) { \
108 return StaticDeletedChain< Type >::validate((const Type *)ptr); \
114 #define ALLOC_DELETED_CHAIN_DECL(Type) \
115 inline void *operator new(size_t size) { \
116 return (void *)_deleted_chain.allocate(size, get_type_handle(Type)); \
118 inline void *operator new(size_t size, void *ptr) { \
122 inline void operator delete(void *ptr) { \
123 _deleted_chain.deallocate((Type *)ptr, get_type_handle(Type)); \
125 inline void operator delete(void *, void *) { \
127 inline static bool validate_ptr(const void *ptr) { \
128 return _deleted_chain.validate((const Type *)ptr); \
130 static DeletedChain< Type > _deleted_chain;
134 #define ALLOC_DELETED_CHAIN_DEF(Type) \
135 DeletedChain< Type > Type::_deleted_chain;
137 #else // USE_DELETED_CHAIN
139 #define ALLOC_DELETED_CHAIN(Type) \
140 inline static bool validate_ptr(const void *ptr) { \
141 return (ptr != NULL); \
143 #define ALLOC_DELETED_CHAIN_DECL(Type) \
144 inline static bool validate_ptr(const void *ptr) { \
145 return (ptr != NULL); \
147 #define ALLOC_DELETED_CHAIN_DEF(Type)
149 #endif // USE_DELETED_CHAIN
151 #include "deletedChain.T"
This template class is used to conveniently declare a single instance of the DeletedChain template ob...
A base class for all things that want to be reference-counted.
TypeHandle is the identifier used to differentiate C++ class types.
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...