Amesos Package Browser (Single Doxygen Collection) Development
amesos_camd_global.c
Go to the documentation of this file.
00001 /* ========================================================================= */
00002 /* === camd_global ========================================================= */
00003 /* ========================================================================= */
00004 
00005 /* ------------------------------------------------------------------------- */
00006 /* CAMD, Copyright (c) Timothy A. Davis, Yanqing Chen,           */
00007 /* Patrick R. Amestoy, and Iain S. Duff.  See ../README.txt for License.     */
00008 /* email: davis at cise.ufl.edu    CISE Department, Univ. of Florida.        */
00009 /* web: http://www.cise.ufl.edu/research/sparse/camd                         */
00010 /* ------------------------------------------------------------------------- */
00011 
00012 #include <stdlib.h>
00013 
00014 #ifdef MATLAB_MEX_FILE
00015 #include "mex.h"
00016 #include "matrix.h"
00017 #endif
00018 
00019 #ifndef NULL
00020 #define NULL 0
00021 #endif
00022 
00023 /* ========================================================================= */
00024 /* === Default CAMD memory manager ========================================= */
00025 /* ========================================================================= */
00026 
00027 /* The user can redefine these global pointers at run-time to change the memory
00028  * manager used by CAMD.  CAMD only uses malloc and free; realloc and calloc are
00029  * include for completeness, in case another package wants to use the same
00030  * memory manager as CAMD.
00031  *
00032  * If compiling as a MATLAB mexFunction, the default memory manager is mxMalloc.
00033  * You can also compile CAMD as a standard ANSI-C library and link a mexFunction
00034  * against it, and then redefine these pointers at run-time, in your
00035  * mexFunction.
00036  *
00037  * If -DNMALLOC is defined at compile-time, no memory manager is specified at
00038  * compile-time.  You must then define these functions at run-time, before
00039  * calling CAMD, for CAMD to work properly.
00040  */
00041 
00042 #ifndef NMALLOC
00043 #ifdef MATLAB_MEX_FILE
00044 /* MATLAB mexFunction: */
00045 void *(*amesos_camd_malloc) (size_t) = mxMalloc ;
00046 void (*amesos_camd_free) (void *) = mxFree ;
00047 void *(*amesos_camd_realloc) (void *, size_t) = mxRealloc ;
00048 void *(*amesos_camd_calloc) (size_t, size_t) = mxCalloc ;
00049 #else
00050 /* standard ANSI-C: */
00051 void *(*amesos_camd_malloc) (size_t) = malloc ;
00052 void (*amesos_camd_free) (void *) = free ;
00053 void *(*amesos_camd_realloc) (void *, size_t) = realloc ;
00054 void *(*amesos_camd_calloc) (size_t, size_t) = calloc ;
00055 #endif
00056 #else
00057 /* no memory manager defined at compile-time; you MUST define one at run-time */
00058 void *(*amesos_camd_malloc) (size_t) = NULL ;
00059 void (*amesos_camd_free) (void *) = NULL ;
00060 void *(*amesos_camd_realloc) (void *, size_t) = NULL ;
00061 void *(*amesos_camd_calloc) (size_t, size_t) = NULL ;
00062 #endif
00063 
00064 /* ========================================================================= */
00065 /* === Default CAMD printf routine ========================================= */
00066 /* ========================================================================= */
00067 
00068 /* The user can redefine this global pointer at run-time to change the printf
00069  * routine used by CAMD.  If NULL, no printing occurs.  
00070  *
00071  * If -DNPRINT is defined at compile-time, stdio.h is not included.  Printing
00072  * can then be enabled at run-time by setting camd_printf to a non-NULL function.
00073  */
00074 
00075 #ifndef NPRINT
00076 #ifdef MATLAB_MEX_FILE
00077 int (*amesos_camd_printf) (const char *, ...) = mexPrintf ;
00078 #else
00079 #include <stdio.h>
00080 int (*amesos_camd_printf) (const char *, ...) = printf ;
00081 #endif
00082 #else
00083 int (*amesos_camd_printf) (const char *, ...) = NULL ;
00084 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines