[svn-commits] jpeeler: branch 1.6.0 r181137 - in /branches/1.6.0: ./ channels/ channels/h32...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Mar 10 23:17:31 CDT 2009


Author: jpeeler
Date: Tue Mar 10 23:17:26 2009
New Revision: 181137

URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=181137
Log:
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
........

Modified:
    branches/1.6.0/   (props changed)
    branches/1.6.0/channels/chan_sip.c
    branches/1.6.0/channels/h323/ast_h323.cxx
    branches/1.6.0/include/asterisk/astmm.h
    branches/1.6.0/include/asterisk/utils.h
    branches/1.6.0/utils/Makefile
    branches/1.6.0/utils/extconf.c

Propchange: branches/1.6.0/
------------------------------------------------------------------------------
Binary property 'trunk-merged' - no diff available.

Modified: branches/1.6.0/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/channels/chan_sip.c?view=diff&rev=181137&r1=181136&r2=181137
==============================================================================
--- branches/1.6.0/channels/chan_sip.c (original)
+++ branches/1.6.0/channels/chan_sip.c Tue Mar 10 23:17:26 2009
@@ -3523,7 +3523,7 @@
 		if (onoff) {
 			if (!ast_exists_extension(NULL, context, ext, 1, NULL)) {
 				ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop",
-					 ast_strdup(peer->name), ast_free, "SIP");
+					 ast_strdup(peer->name), ast_free_ptr, "SIP");
 			}
 		} else if (pbx_find_extension(NULL, NULL, &q, context, ext, 1, NULL, "", E_MATCH)) {
 			ast_context_remove_extension(context, ext, 1, NULL);

Modified: branches/1.6.0/channels/h323/ast_h323.cxx
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/channels/h323/ast_h323.cxx?view=diff&rev=181137&r1=181136&r2=181137
==============================================================================
--- branches/1.6.0/channels/h323/ast_h323.cxx (original)
+++ branches/1.6.0/channels/h323/ast_h323.cxx Tue Mar 10 23:17:26 2009
@@ -137,7 +137,7 @@
 
 int PAsteriskLog::Buffer::sync()
 {
-	char *str = strdup(string);
+	char *str = ast_strdup(string);
 	char *s, *s1;
 	char c;
 
@@ -153,7 +153,7 @@
 		ast_verbose("%s", s);
 		*s1 = c;
 	}
-	free(str);
+	ast_free(str);
 
 	string = PString();
 	char *base = string.GetPointer(2000);
@@ -2138,7 +2138,7 @@
 		/* tell the H.323 stack */
 		SetExternalAddress(H323TransportAddress(localIpAddr, localPort), H323TransportAddress(localIpAddr, localPort + 1));
 		/* clean up allocated memory */
-		free(info);
+		ast_free(info);
 	}
 
 	/* Get the payload code	*/
@@ -2385,7 +2385,7 @@
 			endPoint->SetGateway();
 		}
 		if (prefix)
-			free(prefix);
+			ast_free(prefix);
 	}
 	return 0;
 }

Modified: branches/1.6.0/include/asterisk/astmm.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/include/asterisk/astmm.h?view=diff&rev=181137&r1=181136&r2=181137
==============================================================================
--- branches/1.6.0/include/asterisk/astmm.h (original)
+++ branches/1.6.0/include/asterisk/astmm.h Tue Mar 10 23:17:26 2009
@@ -20,8 +20,15 @@
  * \brief Asterisk memory usage debugging
  */
 
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef _ASTERISK_ASTMM_H
 #define _ASTERISK_ASTMM_H
+
+#ifndef STANDALONE
 
 #define __AST_DEBUG_MALLOC
 
@@ -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 @@
 #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

Modified: branches/1.6.0/include/asterisk/utils.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/include/asterisk/utils.h?view=diff&rev=181137&r1=181136&r2=181137
==============================================================================
--- branches/1.6.0/include/asterisk/utils.h (original)
+++ branches/1.6.0/include/asterisk/utils.h Tue Mar 10 23:17:26 2009
@@ -398,7 +398,6 @@
 
 long int ast_random(void);
 
-#define ast_free free
 
 /*! 
  * \brief free() wrapper
@@ -413,6 +412,7 @@
 	ast_free(ptr);
 }
 #else
+#define ast_free free
 #define ast_free_ptr ast_free
 #endif
 
@@ -597,19 +597,6 @@
 	return res;
 }
 )
-
-#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 */
 

Modified: branches/1.6.0/utils/Makefile
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/utils/Makefile?view=diff&rev=181137&r1=181136&r2=181137
==============================================================================
--- branches/1.6.0/utils/Makefile (original)
+++ branches/1.6.0/utils/Makefile Tue Mar 10 23:17:26 2009
@@ -166,6 +166,9 @@
 hashtest.o: ASTCFLAGS+=-O0 -DSTANDALONE
 
 extconf.o: extconf.c
+extconf.o: ASTCFLAGS+=-DSTANDALONE
+
+conf2ael.o: ASTCFLAGS+=-DSTANDALONE
 
 conf2ael: conf2ael.o ast_expr2f.o ast_expr2.o hashtab.o aelbison.o aelparse.o pbx_ael.o pval.o extconf.o strcompat.o
 

Modified: branches/1.6.0/utils/extconf.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.6.0/utils/extconf.c?view=diff&rev=181137&r1=181136&r2=181137
==============================================================================
--- branches/1.6.0/utils/extconf.c (original)
+++ branches/1.6.0/utils/extconf.c Tue Mar 10 23:17:26 2009
@@ -891,10 +891,10 @@
 /* from utils.h */
 
 #define ast_free free
+#define ast_free_ptr free
 
 #define MALLOC_FAILURE_MSG \
 	ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
-#ifndef __AST_DEBUG_MALLOC
 
 /*!
  * \brief A wrapper for malloc()
@@ -928,97 +928,6 @@
 #define ast_vasprintf(ret, fmt, ap) \
 	_ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap))
 
-#else
-
-/* If astmm is in use, let it handle these.  Otherwise, it will report that
-   all allocations are coming from this header file */
-
-#undef __ast_calloc
-#undef calloc
-#undef ast_calloc
-
-#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)
-
-void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, const char *func)
-{
-	void *p;
-
-	if (!(p = malloc(len)))
-		MALLOC_FAILURE_MSG;
-
-	return p;
-}
-
-void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func)
-{
-	void *p;
-
-	if (!(p = calloc(num, len)))
-		MALLOC_FAILURE_MSG;
-
-	return p;
-}
-
-void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func);
-
-void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func)
-{
-	void *p;
-
-	if (!(p = calloc(num, len)))
-		MALLOC_FAILURE_MSG;
-
-	return p;
-}
-
-void * attribute_malloc __ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func)
-{
-	void *newp;
-
-	if (!(newp = realloc(p, len)))
-		MALLOC_FAILURE_MSG;
-
-	return newp;
-}
-
-char * attribute_malloc __ast_strdup(const char *str, const char *file, int lineno, const char *func)
-{
-	char *newstr = NULL;
-
-	if (str) {
-		if (!(newstr = strdup(str)))
-			MALLOC_FAILURE_MSG;
-	}
-
-	return newstr;
-}
-
-char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func)
-{
-	char *newstr = NULL;
-
-	if (str) {
-		if (!(newstr = strndup(str, len)))
-			MALLOC_FAILURE_MSG;
-	}
-
-	return newstr;
-}
-
-void __ast_free(void *ptr, const char *file, int lineno, const char *func)
-{
-#undef free
-	free(ptr);
-}
-
-#endif /* AST_DEBUG_MALLOC */
-
 
 static unsigned int __unsigned_int_flags_dummy;
 
@@ -1043,8 +952,6 @@
 					} while (0)
 
 
-
-#ifndef __AST_DEBUG_MALLOC
 
 #define MALLOC_FAILURE_MSG \
 	ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file);
@@ -1238,20 +1145,6 @@
 	return res;
 }
 )
-
-#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_vasprintf(a,b,c)	vasprintf(a,b,c)
-
-#endif /* AST_DEBUG_MALLOC */
 
 #if !defined(ast_strdupa) && defined(__GNUC__)
 /*!
@@ -6100,7 +5993,7 @@
 						lastpri = ipri;
 						if (!ast_opt_dont_warn && !strcmp(realext, "_."))
 							ast_log(LOG_WARNING, "The use of '_.' for an extension is strongly discouraged and can have unexpected behavior.  Please use '_X.' instead at line %d\n", v->lineno);
-						if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free, registrar)) {
+						if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free_ptr, global_registrar)) {
 							ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
 						}
 					}




More information about the svn-commits mailing list