1 /*********************************************************************
2 * Clustal Omega - Multiple sequence alignment
4 * Copyright (C) 2010 University College Dublin
6 * Clustal-Omega is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
11 * This file is part of Clustal-Omega.
13 ********************************************************************/
16 * RCS $Id: util.h 230 2011-04-09 15:37:50Z andreas $
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))
41 /* STR_EQ: strings are equal, case sensitive */
42 #define STR_EQ(a,b) (strcmp((a),(b)) == 0)
43 /* STR_NC_EQ: strings are equal, ignoring case */
44 #define STR_NC_EQ(a,b) (strcasecmp((a),(b)) == 0)
47 /* type boolean and false and true defined in stdbool.h */
55 /* clashes with hhalign
62 /* don't use the following directly; use macros provided above instead
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);
68 char *CkStrdup(const char *s);
69 void PermutationArray(int **array, const int len);
70 void RandomUniqueIntArray(int *array, const int array_len, const int max_value);
71 int IntCmp(const void *a, const void *b);
72 bool FileIsWritable(char *pcFileName);
73 void QSortAndTrackIndex(int *piSortedIndices, int *piArrayToSort,
74 const int uArrayLen, const char cOrder, const bool bOverwriteArrayToSort);