OpenMPI  0.1.1
malloc.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana
3  * University Research and Technology
4  * Corporation. All rights reserved.
5  * Copyright (c) 2004-2008 The University of Tennessee and The University
6  * of Tennessee Research Foundation. All rights
7  * reserved.
8  * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
9  * University of Stuttgart. All rights reserved.
10  * Copyright (c) 2004-2005 The Regents of the University of California.
11  * All rights reserved.
12  * $COPYRIGHT$
13  *
14  * Additional copyrights may follow
15  *
16  * $HEADER$
17  */
18 
19 /** @file */
20 
21 #ifndef OPAL_MALLOC_H
22 #define OPAL_MALLOC_H
23 
24 #include "opal_config.h"
25 #include <stdlib.h>
26 
27 /*
28  * THIS FILE CANNOT INCLUDE ANY OTHER OPAL HEADER FILES!!!
29  *
30  * It is included via <opal_config_bottom.h>. Hence, it should not
31  * include ANY other files, nor should it include "opal_config.h".
32  *
33  */
34 
35 /*
36  * Set OPAL_MALLOC_DEBUG_LEVEL to
37  * 0 for no checking
38  * 1 for basic error checking
39  * 2 for more error checking
40  */
41 
42 #ifndef OPAL_MALLOC_DEBUG_LEVEL
43 #define OPAL_MALLOC_DEBUG_LEVEL 2
44 #endif
45 
46 BEGIN_C_DECLS
47  /**
48  * Initialize malloc debug output.
49  *
50  * This function is invoked to setup a dedicated output stream for
51  * malloc debug functions. It does \em not (currently) do anything
52  * other than that (i.e., no internal accounting for tracking
53  * malloc/free statements, etc.).
54  *
55  * It is invoked as part of opal_init(). Although this function is
56  * not \em necessary for OPAL_MALLOC() and OPAL_FREE(), it is strong
57  * recommended because no output messages -- regardless of the
58  * malloc debug level set by opal_malloc_debug() -- will be displayed
59  * unless this function is invoked first.
60  */
61 void opal_malloc_init(void);
62 
63  /**
64  * Shut down malloc debug output.
65  *
66  * This function is invoked as part of opal_finalize() to shut down the
67  * output stream for malloc debug messages.
68  */
69 void opal_malloc_finalize(void);
70 
71  /**
72  * \internal
73  *
74  * Back-end error-checking malloc function for OPAL (you should use
75  * the normal malloc() instead of this function).
76  *
77  * @param size The number of bytes to allocate
78  * @param file Typically the __FILE__ macro
79  * @param line Typically the __LINE__ macro
80  *
81  * This function is only used when --enable-mem-debug was specified to
82  * configure (or by default if you're building in a SVN checkout).
83  */
84 OPAL_DECLSPEC void *opal_malloc(size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
85 
86  /**
87  * \internal
88  *
89  * Back-end error-checking calloc function for OPAL (you should use
90  * the normal calloc() instead of this function).
91  *
92  * @param nmembers Number of elements to malloc
93  * @param size Size of each elements
94  * @param file Typically the __FILE__ macro
95  * @param line Typically the __LINE__ macro
96  *
97  * This function is only used when --enable-mem-debug was specified to
98  * configure (or by default if you're building in a SVN checkout).
99  */
100 OPAL_DECLSPEC void *opal_calloc(size_t nmembers, size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
101 
102  /**
103  * \internal
104  *
105  * Back-end error-checking realloc function for OPAL (you should use
106  * the normal realloc() instead of this function).
107  *
108  * @param ptr Pointer to reallocate
109  * @param size The number of bytes to allocate
110  * @param file Typically the __FILE__ macro
111  * @param line Typically the __LINE__ macro
112  *
113  * This function is only used when --enable-mem-debug was specified to
114  * configure (or by default if you're building in a SVN checkout).
115  */
116 OPAL_DECLSPEC void *opal_realloc(void *ptr, size_t size, const char *file, int line) __opal_attribute_malloc__ __opal_attribute_warn_unused_result__;
117 
118  /**
119  * \internal
120  *
121  * Back-end error-checking free function for OPAL (you should use
122  * free() instead of this function).
123  *
124  * @param addr Address on the heap to free()
125  * @param file Typically the __FILE__ macro
126  * @param line Typically the __LINE__ macro
127  *
128  * This function is only used when --enable-mem-debug was specified
129  * to configure (or by default if you're building in a SVN
130  * checkout).
131  */
132 OPAL_DECLSPEC void opal_free(void *addr, const char *file, int line) __opal_attribute_nonnull__(1);
133 
134 /**
135  * Used to set the debug level for malloc debug.
136  *
137  * @param level The level of debugging (0 = none, 1 = some, 2 = more)
138  *
139  * This value defaults to the OPAL_MALLOC_DEBUG_LEVEL.
140  */
141 OPAL_DECLSPEC void opal_malloc_debug(int level);
142 
143 END_C_DECLS
144 
145 #endif /* OPAL_MALLOC_H */
OPAL_DECLSPEC void opal_malloc_debug(int level)
Used to set the debug level for malloc debug.
Definition: malloc.c:187
BEGIN_C_DECLS void opal_malloc_init(void)
Initialize malloc debug output.
Definition: malloc.c:60
void opal_malloc_finalize(void)
Shut down malloc debug output.
Definition: malloc.c:76