Cantera  2.2.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mdp_allo.h
1 #ifndef MDP_ALLO_H
2 #define MDP_ALLO_H
3 
4 #include <string.h>
5 /*****************************************************************************/
6 /*
7 * If we have array_alloc() from another Sandia program, we will not use
8 * the one from this mdp_array_alloc. Instead we will redefine the names
9 */
10 
11 #ifdef HAVE_ARRAY_ALLOC
12 # define mdp_array_alloc array_alloc
13 # define mdp_safe_free safe_free
14 #endif
15 
16 /*
17  * These are a poor man's way of specifying whether a value should be
18  * initialized. These are seldom used numbers whic
19  * $Name: $
20  *====================h can be used in place
21  * of real ints and dbls to indicate that initialization shouldn't take
22  * place.
23  */
24 #define MDP_INT_NOINIT -68361
25 #define MDP_DBL_NOINIT -1.241E11
26 
27 
28 #ifndef _C16_NAME_DEF
29 # define _C16_NAME_DEF
30 typedef char C16_NAME[16]; /* Character array used for fortran names */
31 typedef char C16_NAME_STR[17];
32 #endif
33 /*****************************************************************************/
34 /*
35  * Externals that should be set by the calling program.
36  * These are only used for debugging purposes.
37  */
38 #ifdef MDP_MPDEBUGIO
39 extern int MDP_MP_Nprocs;
40 extern int MDP_MP_myproc;
41 #endif
42 /*****************************************************************************/
43 
44 #define mdp_alloc_struct(x, num) (x *) mdp_array_alloc(1, (num), sizeof(x))
45 
46 
47 /* function declarations for dynamic array allocation */
48 
49 extern double* mdp_array_alloc(int numdim, ...);
50 extern void mdp_safe_free(void**);
51 
52 extern int* mdp_alloc_int_1(int, const int);
53 extern void mdp_safe_alloc_int_1(int**, int, const int);
54 extern void mdp_realloc_int_1(int**, int, int,
55  const int defval = MDP_INT_NOINIT);
56 extern int** mdp_alloc_int_2(int, int, const int);
57 
58 extern double* mdp_alloc_dbl_1(int, const double);
59 extern void mdp_safe_alloc_dbl_1(double**, int, const double);
60 extern void mdp_realloc_dbl_1(double**, int, int, const double);
61 extern void mdp_realloc_dbl_2(double***, int, int, int, int,
62  const double);
63 
64 extern char* mdp_alloc_char_1(int, const char);
65 extern void mdp_safe_alloc_char_1(char**, int, const char);
66 extern char** mdp_alloc_VecFixedStrings(int, int);
67 extern void mdp_safe_alloc_VecFixedStrings(char***, int, int);
68 extern void mdp_realloc_VecFixedStrings(char***, int, int, int);
69 
70 extern double** mdp_alloc_dbl_2(int, int, const double);
71 extern void mdp_safe_alloc_dbl_2(double***, int, int,
72  const double = MDP_DBL_NOINIT);
73 
74 extern C16_NAME* mdp_alloc_C16_NAME_1(int, const int);
75 extern void mdp_safe_alloc_C16_NAME_1(C16_NAME**, int, const int);
76 
77 extern void** mdp_alloc_ptr_1(int);
78 extern void mdp_safe_alloc_ptr_1(void***, int);
79 extern void mdp_realloc_ptr_1(void***, int, int);
80 extern char* mdp_copy_C16_NAME_to_string(const C16_NAME);
81 extern char* mdp_copy_string(const char*);
82 extern void mdp_safe_copy_string(char**, const char*);
83 
84 extern void*** mdp_alloc_ptr_2(int, int);
85 
86 /*****************************************************************************/
87 #endif
88 /*****************************************************************************/
89