[asterisk-commits] jpeeler: branch 1.4 r181133 - in /branches/1.4: apps/ channels/ channels/h323...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Mar 10 22:25:12 CDT 2009
Author: jpeeler
Date: Tue Mar 10 22:25:04 2009
New Revision: 181133
URL: http://svn.digium.com/svn-view/asterisk?view=rev&rev=181133
Log:
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. Because using the ast prefix calls are
a better choice, ast_free_ptr is the new wrapper for free to pass to functions.
Also, a little bit of clean up was done to avoid the debug macros intentionally
being redefined.
(closes issue #13593)
Reported by: pj
Modified:
branches/1.4/apps/app_meetme.c
branches/1.4/channels/chan_iax2.c
branches/1.4/channels/chan_sip.c
branches/1.4/channels/h323/ast_h323.cxx
branches/1.4/include/asterisk/astmm.h
branches/1.4/include/asterisk/threadstorage.h
branches/1.4/include/asterisk/utils.h
branches/1.4/pbx/pbx_ael.c
branches/1.4/pbx/pbx_config.c
branches/1.4/res/res_features.c
Modified: branches/1.4/apps/app_meetme.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/apps/app_meetme.c?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/apps/app_meetme.c (original)
+++ branches/1.4/apps/app_meetme.c Tue Mar 10 22:25:04 2009
@@ -4729,7 +4729,7 @@
return -1;
}
if (ast_add_extension2(context, 0 /* don't replace */, "s", 1,
- NULL, NULL, slatrunk_app, ast_strdup(trunk->name), ast_free, sla_registrar)) {
+ NULL, NULL, slatrunk_app, ast_strdup(trunk->name), ast_free_ptr, sla_registrar)) {
ast_log(LOG_ERROR, "Failed to automatically create extension "
"for trunk '%s'!\n", trunk->name);
destroy_trunk(trunk);
@@ -4868,7 +4868,7 @@
/* The extension for when the handset goes off-hook.
* exten => station1,1,SLAStation(station1) */
if (ast_add_extension2(context, 0 /* don't replace */, station->name, 1,
- NULL, NULL, slastation_app, ast_strdup(station->name), ast_free, sla_registrar)) {
+ NULL, NULL, slastation_app, ast_strdup(station->name), ast_free_ptr, sla_registrar)) {
ast_log(LOG_ERROR, "Failed to automatically create extension "
"for trunk '%s'!\n", station->name);
destroy_station(station);
@@ -4883,7 +4883,7 @@
/* Extension for this line button
* exten => station1_line1,1,SLAStation(station1_line1) */
if (ast_add_extension2(context, 0 /* don't replace */, exten, 1,
- NULL, NULL, slastation_app, ast_strdup(exten), ast_free, sla_registrar)) {
+ NULL, NULL, slastation_app, ast_strdup(exten), ast_free_ptr, sla_registrar)) {
ast_log(LOG_ERROR, "Failed to automatically create extension "
"for trunk '%s'!\n", station->name);
destroy_station(station);
Modified: branches/1.4/channels/chan_iax2.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/channels/chan_iax2.c?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/channels/chan_iax2.c (original)
+++ branches/1.4/channels/chan_iax2.c Tue Mar 10 22:25:04 2009
@@ -6202,7 +6202,7 @@
if (onoff) {
if (!ast_exists_extension(NULL, regcontext, ext, 1, NULL))
ast_add_extension(regcontext, 1, ext, 1, NULL, NULL,
- "Noop", ast_strdup(peer->name), ast_free, "IAX2");
+ "Noop", ast_strdup(peer->name), ast_free_ptr, "IAX2");
} else
ast_context_remove_extension(regcontext, ext, 1, NULL);
}
Modified: branches/1.4/channels/chan_sip.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/channels/chan_sip.c?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/channels/chan_sip.c (original)
+++ branches/1.4/channels/chan_sip.c Tue Mar 10 22:25:04 2009
@@ -2488,7 +2488,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 {
ast_context_remove_extension(context, ext, 1, NULL);
Modified: branches/1.4/channels/h323/ast_h323.cxx
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/channels/h323/ast_h323.cxx?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/channels/h323/ast_h323.cxx (original)
+++ branches/1.4/channels/h323/ast_h323.cxx Tue Mar 10 22:25:04 2009
@@ -28,6 +28,8 @@
*
* Version Info: $Id$
*/
+#include "asterisk.h"
+
#include <arpa/inet.h>
#include <list>
@@ -152,7 +154,7 @@
ast_verbose("%s", s);
*s1 = c;
}
- free(str);
+ ast_free(str);
string = PString();
char *base = string.GetPointer(2000);
@@ -2015,7 +2017,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 */
@@ -2234,7 +2236,7 @@
endPoint->SetGateway();
}
if (prefix)
- free(prefix);
+ ast_free(prefix);
}
return 0;
}
Modified: branches/1.4/include/asterisk/astmm.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/include/asterisk/astmm.h?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/include/asterisk/astmm.h (original)
+++ branches/1.4/include/asterisk/astmm.h Tue Mar 10 22:25:04 2009
@@ -19,6 +19,11 @@
/*! \file
* \brief Asterisk memory usage debugging
*/
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
#ifndef _ASTERISK_ASTMM_H
#define _ASTERISK_ASTMM_H
@@ -42,6 +47,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);
@@ -60,30 +66,58 @@
#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__)
+
+#ifdef __cplusplus
+}
+#endif
+
#else
#error "NEVER INCLUDE astmm.h DIRECTLY!!"
#endif /* _ASTERISK_ASTMM_H */
Modified: branches/1.4/include/asterisk/threadstorage.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/include/asterisk/threadstorage.h?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/include/asterisk/threadstorage.h (original)
+++ branches/1.4/include/asterisk/threadstorage.h Tue Mar 10 22:25:04 2009
@@ -65,7 +65,7 @@
* \endcode
*/
#define AST_THREADSTORAGE(name, name_init) \
- AST_THREADSTORAGE_CUSTOM(name, name_init, ast_free)
+ AST_THREADSTORAGE_CUSTOM(name, name_init, ast_free_ptr)
#if !defined(DEBUG_THREADLOCALS)
#define AST_THREADSTORAGE_CUSTOM(name, name_init, cleanup) \
Modified: branches/1.4/include/asterisk/utils.h
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/include/asterisk/utils.h?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/include/asterisk/utils.h (original)
+++ branches/1.4/include/asterisk/utils.h Tue Mar 10 22:25:04 2009
@@ -304,17 +304,18 @@
/*!
* \brief free() wrapper
*
- * ast_free should be used when a function pointer for free() needs to be passed
+ * ast_free_ptr should be used when a function pointer for free() needs to be passed
* as the argument to a function. Otherwise, astmm will cause seg faults.
*/
#ifdef __AST_DEBUG_MALLOC
-static void ast_free(void *ptr) attribute_unused;
-static void ast_free(void *ptr)
+static void ast_free_ptr(void *ptr) attribute_unused;
+static void ast_free_ptr(void *ptr)
{
free(ptr);
}
#else
#define ast_free free
+#define ast_free_ptr ast_free
#endif
#ifndef __AST_DEBUG_MALLOC
@@ -496,19 +497,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.4/pbx/pbx_ael.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/pbx/pbx_ael.c?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/pbx/pbx_ael.c (original)
+++ branches/1.4/pbx/pbx_ael.c Tue Mar 10 22:25:04 2009
@@ -4079,7 +4079,7 @@
pbx_substitute_variables_helper(NULL, exten->name, realext, sizeof(realext) - 1);
if (exten->hints) {
if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, PRIORITY_HINT, NULL, exten->cidmatch,
- exten->hints, NULL, ast_free, registrar)) {
+ exten->hints, NULL, ast_free_ptr, registrar)) {
ast_log(LOG_WARNING, "Unable to add step at priority 'hint' of extension '%s'\n",
exten->name);
}
@@ -4159,7 +4159,7 @@
label = 0;
if (ast_add_extension2(exten->context, 0 /*no replace*/, realext, pr->priority_num, (label?label:NULL), exten->cidmatch,
- app, strdup(appargs), ast_free, registrar)) {
+ app, strdup(appargs), ast_free_ptr, registrar)) {
ast_log(LOG_WARNING, "Unable to add step at priority '%d' of extension '%s'\n", pr->priority_num,
exten->name);
}
Modified: branches/1.4/pbx/pbx_config.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/pbx/pbx_config.c?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/pbx/pbx_config.c (original)
+++ branches/1.4/pbx/pbx_config.c Tue Mar 10 22:25:04 2009
@@ -1536,7 +1536,7 @@
if (!app_data)
app_data="";
if (ast_add_extension(argv[4], argc == 6 ? 1 : 0, exten, iprior, NULL, cidmatch, app,
- (void *)strdup(app_data), ast_free, registrar)) {
+ (void *)strdup(app_data), ast_free_ptr, registrar)) {
switch (errno) {
case ENOMEM:
ast_cli(fd, "Out of free memory\n");
@@ -1629,7 +1629,7 @@
if (!app_data)
app_data="";
if (ast_add_extension(argv[5], argc == 7 ? 1 : 0, exten, iprior, NULL, cidmatch, app,
- (void *)strdup(app_data), ast_free, registrar)) {
+ (void *)strdup(app_data), ast_free_ptr, registrar)) {
switch (errno) {
case ENOMEM:
ast_cli(fd, "Out of free memory\n");
@@ -2372,7 +2372,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, registrar)) {
ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
}
}
@@ -2516,9 +2516,9 @@
/* If voicemail, use "stdexten" else use plain old dial */
if (hasvoicemail) {
snprintf(tmp, sizeof(tmp), "stdexten|%s|${HINT}", cat);
- ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Macro", strdup(tmp), ast_free, registrar);
+ ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Macro", strdup(tmp), ast_free_ptr, registrar);
} else {
- ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", strdup("${HINT}"), ast_free, registrar);
+ ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", strdup("${HINT}"), ast_free_ptr, registrar);
}
}
}
Modified: branches/1.4/res/res_features.c
URL: http://svn.digium.com/svn-view/asterisk/branches/1.4/res/res_features.c?view=diff&rev=181133&r1=181132&r2=181133
==============================================================================
--- branches/1.4/res/res_features.c (original)
+++ branches/1.4/res/res_features.c Tue Mar 10 22:25:04 2009
@@ -518,7 +518,7 @@
if (!con) /* Still no context? Bad */
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
if (con) {
- if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, strdup(pu->parkingexten), ast_free, registrar)) {
+ if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, strdup(pu->parkingexten), ast_free_ptr, registrar)) {
notify_metermaids(pu->parkingexten, parking_con);
}
}
@@ -2195,7 +2195,7 @@
snprintf(returnexten, sizeof(returnexten), "%s|30|t", peername);
}
- ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(returnexten), ast_free, registrar);
+ ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", strdup(returnexten), ast_free_ptr, registrar);
}
set_c_e_p(chan, parking_con_dial, peername, 1);
} else {
More information about the asterisk-commits
mailing list