Memory Allocation

Located in file: MEL.hpp

template <typename T>
T *MEL::MemAlloc(const Aint size)

Allocate a block of memory for ‘size’ number of type T.

See
MPI_Alloc_mem
Return
Returns the pointer to the allocated memory
Parameters
  • size -

    The number of elements of type T to allocate

template <typename T>
T *MEL::MemAlloc(const Aint size, const T &val)

Allocate a block of memory for ‘size’ number of type T and assign a default value.

Return
Returns the pointer to the allocated memory
Parameters
  • size -

    The number of elements of type T to allocate

  • val -

    The value to set each element equal to

template <typename T, typename... Args>
T *MEL::MemConstruct(Args&&... args)

Allocate a single object of type T and construct it with the set of varadic arguments.

Return
Returns the pointer to the allocated memory
Parameters
  • args -

    The set of varadic arguments to construct the object with

template <typename T>
void MEL::MemFree(T *&ptr)

Free a pointer allocated with MPI_Alloc or the MEL equivilant functions.

See
MPI_Free_mem
Parameters
  • ptr -

    The pointer to free

template <typename T0, typename T1, typename... Args>
void MEL::MemFree(T0 &d0, T1 &d1, Args&&... args)

Free the varadic set of pointers provided.

Parameters
  • d0 -

    The first pointer to free

  • d1 -

    The second pointer to free

  • args -

    The varadic set of remaining pointers to free

template <typename T>
void MEL::MemDestruct(T *&ptr, const Aint len = 1)

Call the destructor for each element of the given array and then free the memory.

Parameters
  • ptr -

    The pointer to the memory to be destructed

  • len -

    The length of the array