2 * Asterisk -- An open source telephony toolkit.
4 * Copyright (C) 1999 - 2006, Digium, Inc.
6 * Mark Spencer <markster@digium.com>
8 * See http://www.asterisk.org for more information about
9 * the Asterisk project. Please do not directly contact
10 * any of the maintainers of this project for assistance;
11 * the project provides a web site, mailing lists and IRC
12 * channels for your use.
14 * This program is free software, distributed under the terms of
15 * the GNU General Public License Version 2. See the LICENSE file
16 * at the top of the source tree.
20 * \brief Asterisk memory usage debugging
23 #ifndef _ASTERISK_ASTMM_H
24 #define _ASTERISK_ASTMM_H
26 #define __AST_DEBUG_MALLOC
30 /* Include these now to prevent them from being needed later */
31 #include <sys/types.h>
37 /* Undefine any macros */
46 void *__ast_calloc(size_t nmemb
, size_t size
, const char *file
, int lineno
, const char *func
);
47 void *__ast_calloc_cache(size_t nmemb
, size_t size
, const char *file
, int lineno
, const char *func
);
48 void *__ast_malloc(size_t size
, const char *file
, int lineno
, const char *func
);
49 void __ast_free(void *ptr
, const char *file
, int lineno
, const char *func
);
50 void *__ast_realloc(void *ptr
, size_t size
, const char *file
, int lineno
, const char *func
);
51 char *__ast_strdup(const char *s
, const char *file
, int lineno
, const char *func
);
52 char *__ast_strndup(const char *s
, size_t n
, const char *file
, int lineno
, const char *func
);
53 int __ast_asprintf(const char *file
, int lineno
, const char *func
, char **strp
, const char *format
, ...);
54 int __ast_vasprintf(char **strp
, const char *format
, va_list ap
, const char *file
, int lineno
, const char *func
);
56 void __ast_mm_init(void);
59 /* Provide our own definitions */
61 __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
63 #define ast_calloc_cache(a,b) \
64 __ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
67 __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
70 __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
72 #define realloc(a,b) \
73 __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
76 __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
78 #define strndup(a,b) \
79 __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
81 #define asprintf(a, b, c...) \
82 __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
84 #define vasprintf(a,b,c) \
85 __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
88 #error "NEVER INCLUDE astmm.h DIRECTLY!!"
89 #endif /* _ASTERISK_ASTMM_H */