Amesos Package Browser (Single Doxygen Collection)  Development
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
amesos_camd_global.c
Go to the documentation of this file.
1 /* ========================================================================= */
2 /* === camd_global ========================================================= */
3 /* ========================================================================= */
4 
5 /* ------------------------------------------------------------------------- */
6 /* CAMD, Copyright (c) Timothy A. Davis, Yanqing Chen, */
7 /* Patrick R. Amestoy, and Iain S. Duff. See ../README.txt for License. */
8 /* email: davis at cise.ufl.edu CISE Department, Univ. of Florida. */
9 /* web: http://www.cise.ufl.edu/research/sparse/camd */
10 /* ------------------------------------------------------------------------- */
11 
12 #include <stdlib.h>
13 
14 #ifdef MATLAB_MEX_FILE
15 #include "mex.h"
16 #include "matrix.h"
17 #endif
18 
19 #ifndef NULL
20 #define NULL 0
21 #endif
22 
23 /* ========================================================================= */
24 /* === Default CAMD memory manager ========================================= */
25 /* ========================================================================= */
26 
27 /* The user can redefine these global pointers at run-time to change the memory
28  * manager used by CAMD. CAMD only uses malloc and free; realloc and calloc are
29  * include for completeness, in case another package wants to use the same
30  * memory manager as CAMD.
31  *
32  * If compiling as a MATLAB mexFunction, the default memory manager is mxMalloc.
33  * You can also compile CAMD as a standard ANSI-C library and link a mexFunction
34  * against it, and then redefine these pointers at run-time, in your
35  * mexFunction.
36  *
37  * If -DNMALLOC is defined at compile-time, no memory manager is specified at
38  * compile-time. You must then define these functions at run-time, before
39  * calling CAMD, for CAMD to work properly.
40  */
41 
42 #ifndef NMALLOC
43 #ifdef MATLAB_MEX_FILE
44 /* MATLAB mexFunction: */
45 void *(*amesos_camd_malloc) (size_t) = mxMalloc ;
46 void (*amesos_camd_free) (void *) = mxFree ;
47 void *(*amesos_camd_realloc) (void *, size_t) = mxRealloc ;
48 void *(*amesos_camd_calloc) (size_t, size_t) = mxCalloc ;
49 #else
50 /* standard ANSI-C: */
51 void *(*amesos_camd_malloc) (size_t) = malloc ;
52 void (*amesos_camd_free) (void *) = free ;
53 void *(*amesos_camd_realloc) (void *, size_t) = realloc ;
54 void *(*amesos_camd_calloc) (size_t, size_t) = calloc ;
55 #endif
56 #else
57 /* no memory manager defined at compile-time; you MUST define one at run-time */
58 void *(*amesos_camd_malloc) (size_t) = NULL ;
59 void (*amesos_camd_free) (void *) = NULL ;
60 void *(*amesos_camd_realloc) (void *, size_t) = NULL ;
61 void *(*amesos_camd_calloc) (size_t, size_t) = NULL ;
62 #endif
63 
64 /* ========================================================================= */
65 /* === Default CAMD printf routine ========================================= */
66 /* ========================================================================= */
67 
68 /* The user can redefine this global pointer at run-time to change the printf
69  * routine used by CAMD. If NULL, no printing occurs.
70  *
71  * If -DNPRINT is defined at compile-time, stdio.h is not included. Printing
72  * can then be enabled at run-time by setting camd_printf to a non-NULL function.
73  */
74 
75 #ifndef NPRINT
76 #ifdef MATLAB_MEX_FILE
77 int (*amesos_camd_printf) (const char *, ...) = mexPrintf ;
78 #else
79 #include <stdio.h>
80 int (*amesos_camd_printf) (const char *, ...) = printf ;
81 #endif
82 #else
83 int (*amesos_camd_printf) (const char *, ...) = NULL ;
84 #endif
int(* amesos_camd_printf)(const char *,...)
void(* amesos_camd_free)(void *)
#define NULL