UNIVERS  15.3
UNIVERS base processing software API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
dmu.h
1 /* dmu.h */
2 /* $Revision: 1.5 $ dmu.h $Date: 2000/02/11 12:55:24 $ */
3 #ifndef __dmu_h
4 #define __dmu_h
5 
6 /***********************************************************************
7  *
8  * Debugging Memory Usage library ``PAMPERS''
9  *
10  ***********************************************************************/
11 
12 #include <malloc.h>
13 #include <stdlib.h>
14 
15 /* only for Fortran() macro */
16 #include <mix/Types.h>
17 
18 
19 #define DMU_SAFEBAND_ENV "DMU_SAFEBAND" /* 256 default */
20 #define DMU_LEVEL_ENV "DMU_LEVEL" /* "" */
21 #define DMU_FILLCHAR_ENV "DMU_FILLCHAR" /* 0xbe */
22 #define DMU_ABORT_ENV "DMU_ABORT" /* "" (or non-zero) */
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif /* __cplusplus */
27 
28 /* Overload standard methods of memory handling */
29 void* dmu_malloc (size_t size, const char* file, int line);
30 void* dmu_calloc (size_t nmemb, size_t size, const char* file, int line);
31 void* dmu_realloc (void* ptr, size_t size, const char* file, int line);
32 void dmu_free (void* ptr, const char* file, int line);
33 
34 /* Assign fill character code and check band around each memory block */
35 void dmu_init (char fill_char, size_t safe_band);
36 
37 /* Check pointed memory block allocated by dmu_*alloc. 0 is OK */
38 int dmu_check (void* ptr, const char* file, int line);
39 /* FORTRAN specially */
40 int Fortran(dmucheck) (void* ptr);
41 
42 
43 #ifdef __cplusplus
44 };
45 #endif /* __cplusplus */
46 
47 
48 #ifndef __use_standard_malloc__
49 
50 /***********************************************************************
51  * Obscure standard memory handler functions
52  ***********************************************************************/
53 
54 #ifndef __FILE__
55 #define __FILE__ 0
56 #endif /* __FILE__ */
57 
58 #ifndef __LINE__
59 #define __LINE__ -1
60 #endif /* __LINE__ */
61 
62 #define malloc(size) dmu_malloc((size),__FILE__,__LINE__)
63 #define calloc(nmemb,size) dmu_calloc((nmemb),(size),__FILE__,__LINE__)
64 #define realloc(ptr,size) dmu_realloc((ptr),(size),__FILE__,__LINE__)
65 #define free(ptr) dmu_free((ptr),__FILE__,__LINE__)
66 
67 #endif /* __dmu_hides_malloc__ */
68 
69 #endif /* dmu.h */