[asterisk-commits] trunk r13513 - in /trunk: astmm.c include/asterisk/utils.h

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Mar 18 18:39:16 MST 2006


Author: russell
Date: Sat Mar 18 19:39:14 2006
New Revision: 13513

URL: http://svn.digium.com/view/asterisk?rev=13513&view=rev
Log:
When astmm is in use, define ast_malloc and friends to malloc, etc., so that
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.

Modified:
    trunk/astmm.c
    trunk/include/asterisk/utils.h

Modified: trunk/astmm.c
URL: http://svn.digium.com/view/asterisk/trunk/astmm.c?rev=13513&r1=13512&r2=13513&view=diff
==============================================================================
--- trunk/astmm.c (original)
+++ trunk/astmm.c Sat Mar 18 19:39:14 2006
@@ -108,9 +108,9 @@
 	}
 	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);
 		}
 	}

Modified: trunk/include/asterisk/utils.h
URL: http://svn.digium.com/view/asterisk/trunk/include/asterisk/utils.h?rev=13513&r1=13512&r2=13513&view=diff
==============================================================================
--- trunk/include/asterisk/utils.h (original)
+++ trunk/include/asterisk/utils.h Sat Mar 18 19:39:14 2006
@@ -246,6 +246,8 @@
 long int ast_random(void);
 #endif
 
+#ifndef __AST_DEBUG_MALLOC
+
 /*!
   \brief A wrapper for malloc()
 
@@ -382,6 +384,19 @@
 	return newstr;
 }
 )
+
+#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__)
 /*!



More information about the asterisk-commits mailing list