MPHELL  4.0.0
mphell-errors.c
Go to the documentation of this file.
1 /*
2  MPHELL-4.0
3  Author(s): The MPHELL team
4 
5  (C) Copyright 2015-2018 - Institut Fourier / Univ. Grenoble Alpes (France)
6 
7  This file is part of the MPHELL Library.
8  MPHELL is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation, version 3 of the License.
11 
12  MPHELL is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with MPHELL. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
26 #include "mphell-init.h"
27 
28 void
29 mphell_assert_error (const char *filename, int line, const char *expr)
30 {
31  if (filename != NULL && filename[0] != '\0')
32  {
33  fprintf (stderr, "%s:", filename);
34  if (line != -1)
35  {
36  fprintf (stderr, "%d: ", line);
37  }
38  }
39  fprintf (stderr, "MPHELL assertion failed: %s\n", expr);
40  free_mphell();
41  abort();
42 }
43 
44 void
45 mphell_error (char *expr)
46 {
47  if (MPHELL_ASSERT_FILE != NULL && MPHELL_ASSERT_FILE[0] != '\0')
48  {
49  fprintf (stderr, "%s:", MPHELL_ASSERT_FILE);
50  if (MPHELL_ASSERT_LINE != -1)
51  {
52  fprintf (stderr, "%d: ", MPHELL_ASSERT_LINE);
53  }
54  }
55  fprintf (stderr, "MPHELL error: %s\n", expr);
56  free_mphell();
57  abort();
58 }
59 
60 void
61 mphell_error_free (char *expr)
62 {
63  if (MPHELL_ASSERT_FILE != NULL && MPHELL_ASSERT_FILE[0] != '\0')
64  {
65  fprintf (stderr, "%s:", MPHELL_ASSERT_FILE);
66  if (MPHELL_ASSERT_LINE != -1)
67  {
68  fprintf (stderr, "%d: ", MPHELL_ASSERT_LINE);
69  }
70  }
71  fprintf (stderr, "MPHELL error free: %s\n", expr);
72  free(expr);
73  free_mphell();
74  abort();
75 }
void free_mphell()
Free MPHELL memory, especially the big amount of temporary memory.
Definition: mphell-init.c:97
void mphell_error(char *expr)
Write in stderr, filename, line and expr, free mphell.
Definition: mphell-errors.c:45
Declaration of MPHELL initialisation function.
void mphell_error_free(char *expr)
Write in stderr, filename, line and expr, free expr and mphell.
Definition: mphell-errors.c:61
void mphell_assert_error(const char *filename, int line, const char *expr)
Write in stderr, filename, line and expr, free mphell.
Definition: mphell-errors.c:29