Go to the documentation of this file.
25 #ifndef CLUSTALO_UTIL_H
26 #define CLUSTALO_UTIL_H
29 #define CKMALLOC(b) CkMalloc((b), __FUNCTION__, __LINE__)
30 #define CKCALLOC(c, s) CkCalloc((c), (s), __FUNCTION__, __LINE__)
31 #define CKREALLOC(p, b) CkRealloc((p), (b), __FUNCTION__, __LINE__)
32 #define CKFREE(b) ((b)=CkFree((b), __FUNCTION__, __LINE__))
35 #define MAX(a,b) ((a)>(b)?(a):(b))
38 #define MIN(a,b) ((a)<(b)?(a):(b))
42 #define STR_EQ(a,b) (strcmp((a),(b)) == 0)
44 #define STR_NC_EQ(a,b) (strcasecmp((a),(b)) == 0)
64 void *
CkMalloc(
size_t size,
const char *
function,
const int line);
65 void *
CkCalloc(
size_t count,
size_t size,
const char *
function,
const int line);
66 void *
CkRealloc(
void *ptr,
size_t bytes,
const char *
function,
const int line);
67 void *
CkFree(
void *ptr,
const char *
function,
const int line);
71 int IntCmp(
const void *a,
const void *b);
74 const int uArrayLen,
const char cOrder,
const bool bOverwriteArrayToSort);
void QSortAndTrackIndex(int *piSortedIndices, int *piArrayToSort, const int uArrayLen, const char cOrder, const bool bOverwriteArrayToSort)
Sort a given int array in ascending or descending order, while keeping track of the element order.
Definition: util.c:402
void RandomUniqueIntArray(int *array, const int array_len, const int max_value)
Creates an array filled with random, but unique ints of given range. Implementation of the Floyd algo...
Definition: util.c:292
void PermutationArray(int **array, const int len)
Creates an int array of size len with len-1 random but unique integers with values 0–len-1....
Definition: util.c:236
bool FileIsWritable(char *pcFileName)
Test if file is writable. File may or may not exist.
Definition: util.c:465
void * CkFree(void *ptr, const char *function, const int line)
Frees memory.
Definition: util.c:179
char * CkStrdup(const char *s)
safe version of strdup
Definition: util.c:206
int IntCmp(const void *a, const void *b)
int comparison function for qsort
Definition: util.c:328
void * CkCalloc(size_t count, size_t size, const char *function, const int line)
Allocates memory (calloc). Memory will be set to zero.
Definition: util.c:113
void * CkRealloc(void *ptr, size_t bytes, const char *function, const int line)
Reallocates memory.
Definition: util.c:147
void * CkMalloc(size_t size, const char *function, const int line)
Allocates memory (malloc)
Definition: util.c:78