17 #ifndef AGX_ALLOCATOR_H
18 #define AGX_ALLOCATOR_H
28 #if defined(AGX_DEBUG)
35 #if defined(AGX_TRACK_ALLOCATIONS)
38 # pragma warning(push)
39 # pragma warning( disable : 4290 )
41 void *
operator new(
size_t size)
throw(std::bad_alloc);
42 void *
operator new(
size_t size,
void *ptr)
throw();
43 void operator delete(
void *ptr)
throw();
63 const char *getName()
const;
66 void *allocateBytes(
size_t numBytes,
size_t alignment = 16);
69 void deallocateBytes(
void *buffer,
size_t numBytes);
70 void deallocateBytes(
void *buffer);
75 static void* standaloneAllocateBytes(
size_t numBytes,
size_t alignment = 16);
76 static void standaloneDeallocateTypes(
void* buffer);
81 static void initMemory(
void *data,
size_t numBytes,
agx::UInt32 pattern);
84 #ifdef AGX_TRACK_ALLOCATIONS
85 size_t getNumActiveAllocations()
const;
86 size_t getTotalActiveAllocationSize()
const;
90 #if AGX_DEBUG_INTRUSIVE()
95 #ifdef AGX_TRACK_ALLOCATIONS
96 size_t m_numActiveAllocations;
97 size_t m_totalActiveAllocationSize;
105 template <
typename T>
109 Allocator(
const char *name =
"Allocator");
128 template <
typename T>
151 #if AGX_DEBUG_INTRUSIVE()
158 #ifdef AGX_TRACK_ALLOCATIONS
159 m_numActiveAllocations = 0;
160 m_totalActiveAllocationSize = 0;
166 #if AGX_DEBUG_INTRUSIVE()
169 return "AllocatorNameOnlyAvaiableInDebugBuild";
178 template <
typename T>
184 template <
typename T>
190 template <
typename T>
199 template <
typename T>
205 template <
typename T>
211 template <
typename T>
219 #if defined(AGX_TRACK_ALLOCATIONS)
221 # 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)
const char * getName() const
T * allocate(size_t numElements)
AlignedAllocator(const char *name="AlignedAllocator", agx::UInt32 aligment=128)
static agx::UInt32 allocatedMemoryPattern
Allocator(const char *name="Allocator")
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 *)
T * allocate(size_t numElements)
Allocate/deallocate raw memory.
void deallocate(T *buffer)
ByteAllocator(const char *name="ByteAllocator")