Memory Allocation

Macros

#define NewMemClear(t, x)
 
#define NewMem(t, x)
 
#define ReallocMemType(t, p, s)
 
#define DeleteMem(x)
 
#define ClearMemType(t, d, x)
 
#define FillMemType(t, d, x, v)
 
#define CopyMemType(t, s, d, x)
 

Functions

void * MemAllocNC (Int size)
 
void * MemAlloc (Int size)
 
void * MemRealloc (void *orimem, Int size)
 
void MemFree (void *&mem)
 
void _MemFree (void **mem)
 
void CopyMem (const void *s, void *d, Int size)
 
void ClearMem (void *d, Int size, Int32 value=0)
 
Int CompareMem (const void *s, const void *d, Int size)
 
template<class T , class U >
void ClearMemTypeTemplate (T *data_ptr, Int size, const U *check_type)
 
template<class T , class U >
void FillMemTypeTemplate (T *data_ptr, Int size, const U *check_type, Int32 value)
 
template<class T , class U >
void CopyMemTypeTemplate (const T *src_ptr, T *dst_ptr, Int size, const U *check_type)
 

Detailed Description

Macro Definition Documentation

◆ NewMemClear

#define NewMemClear (   t,
 
)

Allocates raw memory and clear it.

Warning
No constructors are called!
Parameters
[in]tType of item (e.g. Char, Float).
[in]xNumber of items. THREADSAFE.
Returns
Pointer to the memory block, or nullptr if allocation failed. The caller owns the pointed memory.

◆ NewMem

#define NewMem (   t,
 
)

Allocates raw memory.

Warning
No constructors are called!
Parameters
[in]tType of item (e.g. Char, Float).
[in]xNumber of items. THREADSAFE.
Returns
Pointer to the memory block, or nullptr if allocation failed. The caller owns the pointed memory.

◆ ReallocMemType

#define ReallocMemType (   t,
  p,
 
)

Resizes raw memory.

Warning
No constructors are called!
Parameters
[in]tType of item (e.g. Char, Float).
[in]pPointer to the previous memory block. Can be nullptr. The caller owns the pointed memory.
[in]sNew number of items. New size of the memory block is s * sizeof(t)) THREADSAFE.
Returns
Pointer to the memory block, or nullptr if resize failed. The caller owns the pointed memory.

◆ DeleteMem

#define DeleteMem (   x)

Frees raw memory block.

Warning
No destructors are called!

◆ ClearMemType

#define ClearMemType (   t,
  d,
 
)

Clears a block of memory of the specified type.

Parameters
[in]tData type (e.g. Char, Float).
[in]dPointer to the block of memory to clear. The caller owns the pointed memory.
[in]xSize of the memory block to clear.

◆ FillMemType

#define FillMemType (   t,
  d,
  x,
 
)

Fills a block of memory of the specified type.

Parameters
[in]tData type (e.g. Char, Float).
[in]dPointer to the block of memory to fill. The caller owns the pointed memory.
[in]xSize of the memory block to fill.
[in]vValue to fill the memory block with.

◆ CopyMemType

#define CopyMemType (   t,
  s,
  d,
 
)

Copies a block of memory of the specified type.

Parameters
[in]tData type (e.g. Char, Float).
[in]sPointer to the source block of memory. The caller owns the pointed memory.
[in]dPointer to the destination block of memory. The caller owns the pointed memory.
[in]xNumber of elements to copy.

Function Documentation

◆ MemAllocNC()

void * MemAllocNC ( Int  size)

Internal.

Memory allocation functions. Overload MemAlloc() / MemFree() for custom memory management.

◆ MemAlloc()

void * MemAlloc ( Int  size)

Internal.

◆ MemRealloc()

void * MemRealloc ( void *  orimem,
Int  size 
)

Internal.

◆ MemFree()

void MemFree ( void *&  mem)

Internal.

◆ _MemFree()

void cineware::_MemFree ( void **  mem)

Internal.

◆ CopyMem()

void cineware::CopyMem ( const void *  s,
void *  d,
Int  size 
)

Copies a block of memory.

Warning
Parameter order is the opposite of memcpy()!
Parameters
[in]sPointer to the source block of memory. The caller owns the pointed memory.
[in]dPointer to the destination block of memory. The caller owns the pointed memory.
[in]sizeSize in bytes of the block of memory to copy.

◆ ClearMem()

void cineware::ClearMem ( void *  d,
Int  size,
Int32  value = 0 
)

Clears a block of memory.

Parameters
[in]dPointer to the block of memory to clear. The caller owns the pointed memory.
[in]sizeSize in bytes of the block of memory to clear.
[in]valueValue to clear the memory block with.

◆ CompareMem()

Int cineware::CompareMem ( const void *  s,
const void *  d,
Int  size 
)

Compares two blocks of memory.

Note
Implementation call memcmp(s, d, size).
Parameters
[in]sFirst block of memory. The caller owns the pointed memory.
[in]dSecond block of memory. The caller owns the pointed memory.
[in]sizeNumber of bytes to compare.
Returns
0 if the contents of both memory blocks are equal.
A value greater than 0 to indicate that the first byte that does not match in both memory blocks has a greater value in s than in d as if evaluated as unsigned char values.
A value less than 0 to indicate that the first byte that does not match in both memory blocks has a less value in s than in d as if evaluated as unsigned char values.
Note
Same return value as memcmp().

◆ ClearMemTypeTemplate()

void cineware::ClearMemTypeTemplate ( T *  data_ptr,
Int  size,
const U *  check_type 
)

Internal.

◆ FillMemTypeTemplate()

void cineware::FillMemTypeTemplate ( T *  data_ptr,
Int  size,
const U *  check_type,
Int32  value 
)

Internal.

◆ CopyMemTypeTemplate()

void cineware::CopyMemTypeTemplate ( const T *  src_ptr,
T *  dst_ptr,
Int  size,
const U *  check_type 
)

Internal.