Defines | Functions

oct-mem.h File Reference

#include <cstddef>
#include <cstring>
#include <algorithm>
#include "oct-cmplx.h"
#include "oct-inttypes.h"
Include dependency graph for oct-mem.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define DEFINE_POD_FILL(T)
#define DEFINE_POD_NEW_DELETE(T)
#define DEFINE_POD_UCOPY(T)

Functions

template<class T >
void copy_or_memcpy (size_t n, const T *src, T *dest)
template<class T >
void fill_or_memset (size_t n, const T &value, T *dest)
template<class T >
bool helper_is_zero_mem (const T &value)
template<class T >
bool helper_is_zero_mem (const std::complex< T > &value)
template<class T >
bool helper_is_zero_mem (const octave_int< T > &value)
template<class T >
void no_ctor_delete (T *ptr)
template<class T >
T * no_ctor_new (size_t n)
size_t safe_size_comp (size_t n, size_t size)

Define Documentation

#define DEFINE_POD_FILL (   T  ) 
Value:
inline void fill_or_memset (size_t n, const T& value, T *dest) \
{ \
  if (helper_is_zero_mem (value)) \
    std::memset (dest, 0, n * sizeof (T)); \
  else \
    std::fill_n (dest, n, value); \
}

Definition at line 97 of file oct-mem.h.

#define DEFINE_POD_NEW_DELETE (   T  ) 
Value:
template <> \
inline T *no_ctor_new<T > (size_t n) \
{ return reinterpret_cast<T *> (new char[safe_size_comp (n, sizeof (T))]); } \
template <> \
inline void no_ctor_delete<T > (T *ptr) \
{ delete [] reinterpret_cast<char *> (ptr); }

Definition at line 137 of file oct-mem.h.

#define DEFINE_POD_UCOPY (   T  ) 
Value:
inline void copy_or_memcpy (size_t n, const T *src, T *dest) \
{ std::memcpy (dest, src, n * sizeof (T)); }

Definition at line 52 of file oct-mem.h.


Function Documentation

template<class T >
void copy_or_memcpy ( size_t  n,
const T *  src,
T *  dest 
) [inline]
template<class T >
void fill_or_memset ( size_t  n,
const T &  value,
T *  dest 
) [inline]
template<class T >
bool helper_is_zero_mem ( const T &  value  )  [inline]

Definition at line 80 of file oct-mem.h.

Referenced by helper_is_zero_mem().

template<class T >
bool helper_is_zero_mem ( const std::complex< T > &  value  )  [inline]

Definition at line 87 of file oct-mem.h.

References helper_is_zero_mem().

template<class T >
bool helper_is_zero_mem ( const octave_int< T > &  value  )  [inline]

Definition at line 94 of file oct-mem.h.

References octave_int< T >::value().

template<class T >
void no_ctor_delete ( T *  ptr  )  [inline]

Definition at line 134 of file oct-mem.h.

template<class T >
T* no_ctor_new ( size_t  n  )  [inline]

Definition at line 126 of file oct-mem.h.

References safe_size_comp().

size_t safe_size_comp ( size_t  n,
size_t  size 
) [inline]

Definition at line 39 of file oct-mem.h.

Referenced by no_ctor_new().

 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines