aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-11 04:33:29 +0000
committerjpeeler <jpeeler@f38db490-d61c-443f-a65b-d21fe96a405b>2009-03-11 04:33:29 +0000
commitb640110f2bd9b080609bc3d996700ea920c514aa (patch)
tree3ec26e4d119dc9d1d2496b168160c82784fb939b /include
parent3d2aefe45065f834a047bf7d6414e95db778babf (diff)
Merged revisions 181135 via svnmerge from
https://origsvn.digium.com/svn/asterisk/trunk ........ r181135 | jpeeler | 2009-03-10 23:06:44 -0500 (Tue, 10 Mar 2009) | 20 lines Fix malloc debug macros to work properly with h323. The main problem here was that cstdlib was undefining free thereby causing the proper debug macros to not be used. ast_h323.cxx has been changed to call ast_free instead to avoid the issue. A few other issues were addressed: - There were a few instances of functions improperly passing ast_free instead of ast_free_ptr. - Some clean up was done to avoid the debug macros intentionally being redefined. (copied below from Kevin's commit, appreciate the help) - disable astmm.h from doing anything when STANDALONE is defined, which is used by the tools in the utils/ directory that use parts of Asterisk header files in hackish ways; also ensure that utils/extconf.c and utils/conf2ael.c are compiled with STANDALONE defined. (closes issue #13593) Reported by: pj ........ git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.6.1@181199 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'include')
-rw-r--r--include/asterisk/astmm.h38
-rw-r--r--include/asterisk/utils.h15
2 files changed, 39 insertions, 14 deletions
diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h
index 553587942..26273c938 100644
--- a/include/asterisk/astmm.h
+++ b/include/asterisk/astmm.h
@@ -20,9 +20,16 @@
* \brief Asterisk memory usage debugging
*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
#ifndef _ASTERISK_ASTMM_H
#define _ASTERISK_ASTMM_H
+#ifndef STANDALONE
+
#define __AST_DEBUG_MALLOC
#include "asterisk.h"
@@ -42,6 +49,7 @@
#undef strndup
#undef asprintf
#undef vasprintf
+#undef free
void *__ast_calloc(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
void *__ast_calloc_cache(size_t nmemb, size_t size, const char *file, int lineno, const char *func);
@@ -61,30 +69,60 @@ void __ast_mm_init(void);
#define calloc(a,b) \
__ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_calloc(a,b) \
+ __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define ast_calloc_cache(a,b) \
__ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
#define malloc(a) \
__ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_malloc(a) \
+ __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define free(a) \
__ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_free(a) \
+ __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define realloc(a,b) \
__ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_realloc(a,b) \
+ __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define strdup(a) \
__ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_strdup(a) \
+ __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define strndup(a,b) \
__ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_strndup(a,b) \
+ __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
#define asprintf(a, b, c...) \
__ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
+#define ast_asprintf(a, b, c...) \
+ __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c)
+
#define vasprintf(a,b,c) \
__ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+#define ast_vasprintf(a,b,c) \
+ __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__)
+
+#endif /* !STANDALONE */
+
#else
#error "NEVER INCLUDE astmm.h DIRECTLY!!"
#endif /* _ASTERISK_ASTMM_H */
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h
index c2c88cca2..107444cb9 100644
--- a/include/asterisk/utils.h
+++ b/include/asterisk/utils.h
@@ -398,7 +398,6 @@ char *ast_process_quotes_and_slashes(char *start, char find, char replace_with);
long int ast_random(void);
-#define ast_free free
/*!
* \brief free() wrapper
@@ -413,6 +412,7 @@ static void ast_free_ptr(void *ptr)
ast_free(ptr);
}
#else
+#define ast_free free
#define ast_free_ptr ast_free
#endif
@@ -598,19 +598,6 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c
}
)
-#else
-
-/* If astmm is in use, let it handle these. Otherwise, it will report that
- all allocations are coming from this header file */
-
-#define ast_malloc(a) malloc(a)
-#define ast_calloc(a,b) calloc(a,b)
-#define ast_realloc(a,b) realloc(a,b)
-#define ast_strdup(a) strdup(a)
-#define ast_strndup(a,b) strndup(a,b)
-#define ast_asprintf(a,b,...) asprintf(a,b,__VA_ARGS__)
-#define ast_vasprintf(a,b,c) vasprintf(a,b,c)
-
#endif /* AST_DEBUG_MALLOC */
#if !defined(ast_strdupa) && defined(__GNUC__)