Streamer fluid modeling - An overview of ARCoS  1.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
misc.c
Go to the documentation of this file.
1 
5 #include <stdlib.h>
6 #include <stdio.h>
7 
8 extern char *invok_name;
9 
11 void*
12 xmalloc (size_t size)
13 {
14  void *value = malloc(size);
15  if (value == 0) {
16  fprintf (stderr, "%s: virtual memory exhausted", invok_name);
17  exit (1);
18  }
19  return value;
20 }
21 
23 void *
24 xrealloc (void *ptr, size_t size)
25 {
26  void *value = realloc (ptr, size);
27  if (value == 0) {
28  fprintf (stderr, "%s: Virtual memory exhausted", invok_name);
29  exit (1);
30  }
31  return value;
32 }
33 
34 
36 void*
37 xcalloc (size_t count, size_t size)
38 {
39  void *value;
40 
41  value = calloc (count, size);
42  if (value == 0){
43  fprintf (stderr, "%s: virtual memory exhausted", invok_name);
44  exit (1);
45  }
46  return value;
47 }