25 T *res = (T*)std::malloc(
sizeof(T)*size);
26 if(!res) { printf(
"Error: SafeMalloc\n"); exit(1); }
37 T *res = (T*)std::calloc(size,
sizeof(T));
38 if(!res) { printf(
"Error: SafeCalloc\n"); exit(1); }
50 T *res = (T*)std::realloc(old,
sizeof(T)*size);
51 if(!res) { printf(
"Error: SafeRealloc\n"); exit(1); }
62 if(*ptr) {free(*ptr);}
73void Copy(T *in, T *out,
int size)
75 #pragma omp parallel for
76 for(
int i=0; i<size; i++) {
88void Set(T val, T *out,
int size)
90 #pragma omp parallel for
91 for(
int i=0; i<size; i++) {
103template <
typename T1,
typename T2>
106 #pragma omp parallel for
107 for(
int i=0; i<size; i++) {
void Convert(T1 *in, T2 *out, int size)
Convert type of arrays.
void Copy(T *in, T *out, int size)
Copy in to out.
void Set(T val, T *out, int size)
Set values of out to val.
void SafeFree(T **ptr)
Free allocated memory.
T * SafeMalloc(int size)
Allocate memory.
T * SafeCalloc(int size)
Allocate memory and clear it.
T * SafeRealloc(T *old, int size)
Reallocate memory.
The top-level namespace of SenK.