14 #ifndef DELETEDCHAIN_H 15 #define DELETEDCHAIN_H 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 StaticDeletedChain< Type >::deallocate((Type *)ptr, get_type_handle(Type)); \ 90 inline void operator delete(void *, void *) { \ 92 inline static bool validate_ptr(const void *ptr) { \ 93 return StaticDeletedChain< Type >::validate((const Type *)ptr); \ 98 #define ALLOC_DELETED_CHAIN_DECL(Type) \ 99 inline void *operator new(size_t size) RETURNS_ALIGNED(MEMORY_HOOK_ALIGNMENT) { \ 100 return (void *)_deleted_chain.allocate(size, get_type_handle(Type)); \ 102 inline void *operator new(size_t size, void *ptr) { \ 106 inline void operator delete(void *ptr) { \ 107 _deleted_chain.deallocate((Type *)ptr, get_type_handle(Type)); \ 109 inline void operator delete(void *, void *) { \ 111 inline static bool validate_ptr(const void *ptr) { \ 112 return _deleted_chain.validate((const Type *)ptr); \ 114 static DeletedChain< Type > _deleted_chain; 118 #define ALLOC_DELETED_CHAIN_DEF(Type) \ 119 DeletedChain< Type > Type::_deleted_chain; 121 #else // USE_DELETED_CHAIN 123 #define ALLOC_DELETED_CHAIN(Type) \ 124 inline static bool validate_ptr(const void *ptr) { \ 125 return (ptr != nullptr); \ 127 #define ALLOC_DELETED_CHAIN_DECL(Type) \ 128 inline static bool validate_ptr(const void *ptr) { \ 129 return (ptr != nullptr); \ 131 #define ALLOC_DELETED_CHAIN_DEF(Type) 133 #endif // USE_DELETED_CHAIN 135 #include "deletedChain.T" PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
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.