~ubuntu-branches/ubuntu/natty/suitesparse/natty

« back to all changes in this revision

Viewing changes to AMD/Source/amd_global.c

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme
  • Date: 2006-12-22 10:16:15 UTC
  • Revision ID: james.westby@ubuntu.com-20061222101615-2ohaj8902oix2rnk
Tags: upstream-2.3.1
ImportĀ upstreamĀ versionĀ 2.3.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ========================================================================= */
 
2
/* === amd_global ========================================================== */
 
3
/* ========================================================================= */
 
4
 
 
5
/* ------------------------------------------------------------------------- */
 
6
/* AMD Version 2.0, Copyright (c) 2006 by Timothy A. Davis,                  */
 
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/amd                          */
 
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 AMD memory manager ========================================== */
 
25
/* ========================================================================= */
 
26
 
 
27
/* The user can redefine these global pointers at run-time to change the memory
 
28
 * manager used by AMD.  AMD 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 AMD.
 
31
 *
 
32
 * If compiling as a MATLAB mexFunction, the default memory manager is mxMalloc.
 
33
 * You can also compile AMD 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 AMD, for AMD to work properly.
 
40
 */
 
41
 
 
42
#ifndef NMALLOC
 
43
#ifdef MATLAB_MEX_FILE
 
44
/* MATLAB mexFunction: */
 
45
void *(*amd_malloc) (size_t) = mxMalloc ;
 
46
void (*amd_free) (void *) = mxFree ;
 
47
void *(*amd_realloc) (void *, size_t) = mxRealloc ;
 
48
void *(*amd_calloc) (size_t, size_t) = mxCalloc ;
 
49
#else
 
50
/* standard ANSI-C: */
 
51
void *(*amd_malloc) (size_t) = malloc ;
 
52
void (*amd_free) (void *) = free ;
 
53
void *(*amd_realloc) (void *, size_t) = realloc ;
 
54
void *(*amd_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 *(*amd_malloc) (size_t) = NULL ;
 
59
void (*amd_free) (void *) = NULL ;
 
60
void *(*amd_realloc) (void *, size_t) = NULL ;
 
61
void *(*amd_calloc) (size_t, size_t) = NULL ;
 
62
#endif
 
63
 
 
64
/* ========================================================================= */
 
65
/* === Default AMD printf routine ========================================== */
 
66
/* ========================================================================= */
 
67
 
 
68
/* The user can redefine this global pointer at run-time to change the printf
 
69
 * routine used by AMD.  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 amd_printf to a non-NULL function.
 
73
 */
 
74
 
 
75
#ifndef NPRINT
 
76
#ifdef MATLAB_MEX_FILE
 
77
int (*amd_printf) (const char *, ...) = mexPrintf ;
 
78
#else
 
79
#include <stdio.h>
 
80
int (*amd_printf) (const char *, ...) = printf ;
 
81
#endif
 
82
#else
 
83
int (*amd_printf) (const char *, ...) = NULL ;
 
84
#endif