]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
When astmm is in use, define ast_malloc and friends to malloc, etc., so that
authorRussell Bryant <russell@russellbryant.com>
Sun, 19 Mar 2006 01:39:14 +0000 (01:39 +0000)
committerRussell Bryant <russell@russellbryant.com>
Sun, 19 Mar 2006 01:39:14 +0000 (01:39 +0000)
it doesn't report that all allocations are coming from utils.h.  Also, add some
more information to the error message astmm reports when a memory allocation
failure occurs.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@13513 65c4cc65-6c06-0410-ace0-fbb531ad65f3

astmm.c
include/asterisk/utils.h

diff --git a/astmm.c b/astmm.c
index 122504a58ca6eec2f8ddb5289ff15c5447a3c94a..c3b26a3562d31346df424c48791292e2b12d70c0 100644 (file)
--- a/astmm.c
+++ b/astmm.c
@@ -108,9 +108,9 @@ static inline void *__ast_alloc_region(size_t size, const enum func_type which,
        }
        ast_mutex_unlock(&reglock);
        if (!reg) {
-               fprintf(stderr, "Memory allocation failure\n");
+               fprintf(stderr, "Memory Allocation Failure - '%d' bytes in function %s at line %d of %s\n", (int) size, func, lineno, file);
                if (mmlog) {
-                       fprintf(mmlog, "%ld - Memory allocation failure\n", time(NULL));
+                       fprintf(stderr, "%ld - Memory Allocation Failure - '%d' bytes in function %s at line %d of %s\n", time(NULL), (int) size, func, lineno, file);
                        fflush(mmlog);
                }
        }
index 416f362f69ce400923ffe6ae74f79cfcd00cf4a2..c702fa6fb64d2107e55e5548627c69619e9c0ac7 100644 (file)
@@ -246,6 +246,8 @@ int getloadavg(double *list, int nelem);
 long int ast_random(void);
 #endif
 
+#ifndef __AST_DEBUG_MALLOC
+
 /*!
   \brief A wrapper for malloc()
 
@@ -383,6 +385,19 @@ char *_ast_strndup(const char *str, size_t len, const char *file, int lineno, co
 }
 )
 
+#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)
+
+#endif /* AST_DEBUG_MALLOC */
+
 #if !defined(ast_strdupa) && defined(__GNUC__)
 /*!
   \brief duplicate a string in memory from the stack