defaultallocator.h File Reference

Classes

class  DefaultAllocator
 

Namespaces

 maxon
 

Macros

#define NewObj(T, ...)
 
#define NewObjClear(T, ...)
 
#define ALLOC_TYPENAME
 
#define DeleteObj(obj)
 
#define NewMem(T, cnt)
 
#define NewMemClear(T, cnt)
 
#define ReallocMem(p, cnt)
 
#define DeleteMem(p)
 

Functions

void * _DefaultAllocNC (Int size, Int32 line, const Char *file)
 
void * _DefaultAlloc (Int size, Int32 line, const Char *file)
 
void * _DefaultReallocNC (void *data, Int size, Int32 line, const Char *file)
 
void _DefaultFree (void **data_ptr)
 
template<typename T >
void DeleteConstPtrObj (T *o)
 
template<typename T >
T * _ReallocMem (T *p, Int cnt, const maxon::SourceLocation &allocLocation)
 
template<typename T >
void ClearMemType (T *data_ptr, Int cnt, UChar value=0)
 

Macro Definition Documentation

§ NewObj

#define NewObj (   T,
  ... 
)

Creates an object with constructor parameters (using new or T::Alloc, depending on the type). This does not throw any kind of exception, it returns null if the allocation fails. Usage: MyType* x = NewObj(MyType, optional constructor parameters);

Parameters
[in]TType of object.
[in]...Additional constructor parameters. THREADSAFE.
Returns
Pointer to object (null if allocation failed)

§ NewObjClear

#define NewObjClear (   T,
  ... 
)

§ ALLOC_TYPENAME

#define ALLOC_TYPENAME

§ DeleteObj

#define DeleteObj (   obj)

Deletes an object. This expects a pointer as argument, the object is deleted using the destructor or T::Free, depending on the type of the object. THREADSAFE.

Parameters
[in,out]objObject pointer (can be nullptr, will be nullptr after return)

§ NewMem

#define NewMem (   T,
  cnt 
)

Allocates raw memory: no constructors are called!

Parameters
[in]TType of item (e.g. Char, Float)
[in]cntNumber of items. THREADSAFE.
Returns
Pointer to memory block or nullptr.

§ NewMemClear

#define NewMemClear (   T,
  cnt 
)

Allocates raw memory and clears it: no constructors are called!

Parameters
[in]TType of item (e.g. Char, Float)
[in]cntNumber of items. THREADSAFE.
Returns
Pointer to memory block or nullptr.

§ ReallocMem

#define ReallocMem (   p,
  cnt 
)

Resizes a raw memory block: no constructors are called!

Parameters
[in]pPrevious memory block (can be nullptr)
[in]cntNew number of items (size of the memory block is n * sizeof(T)) THREADSAFE.
Returns
Pointer to memory block or nullptr.

§ DeleteMem

#define DeleteMem (   p)

Frees a raw memory block: no destructors are called!

Parameters
[in]pMemory block (can be nullptr, will be nullptr after return) THREADSAFE