Corrected some in-line help strings...
[midnight-commander.git] / src / mad.h
blob9351f523168d6b12423710028d98f865286872f7
1 #ifndef __MAD_H
2 #define __MAD_H
4 /* To prevent molesting these files with the malloc/calloc/free macros. */
5 #include <stdio.h>
6 #include <stdlib.h>
7 #if !defined(STDC_HEADERS) && defined(HAVE_MALLOC_H)
8 # include <malloc.h>
9 #endif
11 #ifdef HAVE_MAD
12 # define INLINE
13 #else
14 # ifndef INLINE
15 # define INLINE inline
16 # endif
17 #endif
19 #ifdef HAVE_MAD
20 #include <stdarg.h>
22 /* The Memory Allocation Debugging system */
24 /* GNU headers define this as macros */
25 #ifdef malloc
26 # undef malloc
27 #endif
29 #ifdef calloc
30 # undef calloc
31 #endif
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__)
39 #ifdef strdup
40 # undef strdup
41 #endif
42 #define strdup(x) mad_strdup (x, __FILE__, __LINE__)
43 #ifdef strndup
44 # undef strndup
45 #endif
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.
54 #define MAD_GLIB
55 #ifdef MAD_GLIB
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__)
74 #endif /* MAD_GLIB */
76 void mad_init (void);
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);
92 #else
94 #define mad_init()
95 #define mad_finalize(x, y)
96 #define mad_check(file,line)
98 #endif /* HAVE_MAD */
100 #endif /* __MAD_H */