4 /* To prevent molesting these files with the malloc/calloc/free macros. */
7 #if !defined(STDC_HEADERS) && defined(HAVE_MALLOC_H)
15 # define INLINE inline
22 /* The Memory Allocation Debugging system */
24 /* GNU headers define this as macros */
33 #define tempnam(x,y) mad_tempnam (x, y, __FILE__, __LINE__)
35 #define malloc(x) mad_alloc (x, __FILE__, __LINE__)
36 #define calloc(x, y) mad_alloc0 ((x) * (y), __FILE__, __LINE__)
37 #define realloc(x, y) mad_realloc (x, y, __FILE__, __LINE__)
38 #define xmalloc(x, y) mad_alloc (x, __FILE__, __LINE__)
42 #define strdup(x) mad_strdup (x, __FILE__, __LINE__)
46 #define strndup(x, n) mad_strndup (x, n, __FILE__, __LINE__)
47 #define free(x) mad_free (x, __FILE__, __LINE__)
50 * Define MAD_GLIB to debug allocations in glib as well.
51 * This code is not functional yet.
56 /* These definitions are grabbed from GLib.h */
57 #define g_new(type, count) \
58 ((type *) g_malloc ((unsigned) sizeof (type) * (count)))
59 #define g_new0(type, count) \
60 ((type *) g_malloc0 ((unsigned) sizeof (type) * (count)))
61 #define g_renew(type, mem, count) \
62 ((type *) g_realloc (mem, (unsigned) sizeof (type) * (count)))
64 #define g_malloc(x) mad_alloc (x, __FILE__, __LINE__)
65 #define g_malloc0(x) mad_alloc0 (x, __FILE__, __LINE__)
66 #define g_realloc(x, y) mad_realloc (x, y, __FILE__, __LINE__)
67 #define g_strdup(x) mad_strdup (x, __FILE__, __LINE__)
68 #define g_strndup(x, n) mad_strndup (x, n, __FILE__, __LINE__)
69 #define g_free(x) mad_free (x, __FILE__, __LINE__)
70 #define g_strconcat mad_strconcat
71 #define g_strdup_printf mad_strdup_printf
72 #define g_strdup_vprintf mad_strdup_vprintf
73 #define g_get_current_dir() mad_get_current_dir (__FILE__, __LINE__)
77 void mad_set_debug (const char *file
);
78 void mad_check (const char *file
, int line
);
79 void *mad_alloc (int size
, const char *file
, int line
);
80 void *mad_alloc0 (int size
, const char *file
, int line
);
81 void *mad_realloc (void *ptr
, int newsize
, const char *file
, int line
);
82 char *mad_strdup (const char *s
, const char *file
, int line
);
83 char *mad_strndup (const char *s
, int n
, const char *file
, int line
);
84 void mad_free (void *ptr
, const char *file
, int line
);
85 void mad_finalize (const char *file
, int line
);
86 char *mad_tempnam (char *s1
, char *s2
, const char *file
, int line
);
87 char *mad_strconcat (const char *first
, ...);
88 char *mad_strdup_printf (const char *format
, ...);
89 char *mad_strdup_vprintf (const char *format
, va_list args
);
90 char *mad_get_current_dir (const char *file
, int line
);
95 #define mad_finalize(x, y)
96 #define mad_check(file,line)