17 #ifndef AGX_ALLOCATOR_H 18 #define AGX_ALLOCATOR_H 20 #include <agx/config/AGX_DEBUG_INTRUSIVE.h> 28 #if defined(AGX_DEBUG) 32 #if defined(AGX_TRACK_ALLOCATIONS) 36 # pragma warning(push) 37 # pragma warning( disable : 4290 ) 43 void *
operator new(
size_t size)
throw(std::bad_alloc);
44 void *
operator new(
size_t size,
void *ptr)
throw();
45 void operator delete(
void *ptr)
throw();
65 const char *getName()
const;
68 void *allocateBytes(
size_t numBytes,
size_t alignment = 16);
71 void deallocateBytes(
void *buffer,
size_t numBytes);
72 void deallocateBytes(
void *buffer);
77 static void* standaloneAllocateBytes(
size_t numBytes,
size_t alignment = 16);
78 static void standaloneDeallocateTypes(
void* buffer);
83 static void initMemory(
void *data,
size_t numBytes,
agx::UInt32 pattern);
86 #ifdef AGX_TRACK_ALLOCATIONS 87 size_t getNumActiveAllocations()
const;
88 size_t getTotalActiveAllocationSize()
const;
92 #if AGX_DEBUG_INTRUSIVE() 97 #ifdef AGX_TRACK_ALLOCATIONS 98 size_t m_numActiveAllocations;
99 size_t m_totalActiveAllocationSize;
107 template <
typename T>
111 Allocator(
const char *name =
"Allocator");
114 T *allocate(
size_t numElements);
115 void deallocate(T *buffer);
130 template <
typename T>
137 T *allocate(
size_t numElements);
138 void deallocate(T *buffer);
153 #if AGX_DEBUG_INTRUSIVE() 160 #ifdef AGX_TRACK_ALLOCATIONS 161 m_numActiveAllocations = 0;
162 m_totalActiveAllocationSize = 0;
168 #if AGX_DEBUG_INTRUSIVE() 171 return "AllocatorNameOnlyAvaiableInDebugBuild";
180 template <
typename T>
186 template <
typename T>
192 template <
typename T>
201 template <
typename T>
207 template <
typename T>
213 template <
typename T>
221 #if defined(AGX_TRACK_ALLOCATIONS) 223 # pragma warning(pop)
The Container is the base class for several of the container classes proided by AGX, such as agx::Vector and agx::HashSet.
void deallocate(T *buffer)
T * allocate(size_t numElements)
AlignedAllocator(const char *name="AlignedAllocator", agx::UInt32 aligment=128)
static agx::UInt32 allocatedMemoryPattern
Allocator(const char *name="Allocator")
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
void deallocateBytes(void *buffer, size_t numBytes)
Deallocate a section previously allocated using allocateBytes method.
static bool initMemoryFlag
void * allocateBytes(size_t numBytes, size_t alignment=16)
Allocate a memory section of specified alignment.
static agx::UInt32 deallocatedMemoryPattern
void setContainer(class Container *)
const char * getName() const
T * allocate(size_t numElements)
Allocate/deallocate raw memory.
void deallocate(T *buffer)
ByteAllocator(const char *name="ByteAllocator")