"Fossies" - the Fresh Open Source Software Archive

Member "harminv-1.4.2/check.h" (6 Feb 2023, 2019 Bytes) of package /linux/privat/harminv-1.4.2.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "check.h" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.4.1_vs_1.4.2.

    1 /* Copyright (C) 2017 Massachusetts Institute of Technology.
    2  *
    3  * This program is free software; you can redistribute it and/or modify
    4  * it under the terms of the GNU General Public License as published by
    5  * the Free Software Foundation; either version 2 of the License, or
    6  * (at your option) any later version.
    7  *
    8  * This program is distributed in the hope that it will be useful,
    9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
   10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   11  * GNU General Public License for more details.
   12  *
   13  * You should have received a copy of the GNU General Public License
   14  * along with this program; if not, write to the Free Software
   15  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   16  */
   17 
   18 #ifndef CHECK_H
   19 #define CHECK_H
   20 
   21 /* some useful error-checking macros: */
   22 
   23 #define CHECK(condition, message)                                                                  \
   24   do {                                                                                             \
   25     if (!(condition)) {                                                                            \
   26       fprintf(stderr, "harminv: failure on line %d of " __FILE__ ": " message "\n", __LINE__);     \
   27       exit(EXIT_FAILURE);                                                                          \
   28     }                                                                                              \
   29   } while (0)
   30 
   31 #define CHK_MALLOC(p, t, n)                                                                        \
   32   do {                                                                                             \
   33     size_t CHK_MALLOC_n_tmp = (n);                                                                 \
   34     (p) = (t *)malloc(sizeof(t) * CHK_MALLOC_n_tmp);                                               \
   35     CHECK((p) || CHK_MALLOC_n_tmp == 0, "out of memory!");                                         \
   36   } while (0)
   37 
   38 #endif /* CHECK_H */