diff --git a/apps/app_dial.c b/apps/app_dial.c index 5006e60092..ce763653f8 100644 --- a/apps/app_dial.c +++ b/apps/app_dial.c @@ -1970,7 +1970,7 @@ static int load_module(void) if (!con) ast_log(LOG_ERROR, "Dial virtual context 'app_dial_gosub_virtual_context' does not exist and unable to create\n"); else - ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free, "app_dial"); + ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free_ptr, "app_dial"); res = ast_register_application(app, dial_exec, synopsis, descrip); res |= ast_register_application(rapp, retrydial_exec, rsynopsis, rdescrip); diff --git a/apps/app_meetme.c b/apps/app_meetme.c index d353c3d9db..8dfa382c2c 100644 --- a/apps/app_meetme.c +++ b/apps/app_meetme.c @@ -4715,7 +4715,7 @@ static int sla_build_trunk(struct ast_config *cfg, const char *cat) 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); @@ -4854,7 +4854,7 @@ static int sla_build_station(struct ast_config *cfg, const char *cat) /* 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); @@ -4869,7 +4869,7 @@ static int sla_build_station(struct ast_config *cfg, const char *cat) /* 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); diff --git a/apps/app_queue.c b/apps/app_queue.c index 6ec2dd1d72..ee40bf40ca 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -4979,7 +4979,7 @@ static int load_module(void) if (!con) ast_log(LOG_ERROR, "Queue virtual context 'app_queue_gosub_virtual_context' does not exist and unable to create\n"); else - ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free, "app_queue"); + ast_add_extension2(con, 1, "s", 1, NULL, NULL, "KeepAlive", ast_strdup(""), ast_free_ptr, "app_queue"); if (queue_persistent_members) reload_queue_members(); diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index a238640bd0..bda2de8645 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -6057,7 +6057,7 @@ static void register_peer_exten(struct iax2_peer *peer, int onoff) 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); } diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 880eb2e0cd..8c4fb4e730 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -2906,7 +2906,7 @@ static void register_peer_exten(struct sip_peer *peer, int onoff) } if (onoff) 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); } diff --git a/channels/chan_skinny.c b/channels/chan_skinny.c index da04dbf7e4..69fa9536f2 100644 --- a/channels/chan_skinny.c +++ b/channels/chan_skinny.c @@ -1628,7 +1628,7 @@ static void register_exten(struct skinny_line *l) context = regcontext; } ast_add_extension(context, 1, ext, 1, NULL, NULL, "Noop", - ast_strdup(l->name), ast_free, "Skinny"); + ast_strdup(l->name), ast_free_ptr, "Skinny"); } } diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index d87ea03395..efde93d59e 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -408,20 +408,22 @@ 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 * - * 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); + ast_free(ptr); } #else -#define ast_free free +#define ast_free_ptr ast_free #endif #ifndef __AST_DEBUG_MALLOC diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 77862d0c17..449bf3583c 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -1439,7 +1439,7 @@ static int pbx_load_config(const char *config_file) 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); } } @@ -1567,9 +1567,9 @@ static void pbx_load_users(void) /* 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); } } } diff --git a/res/ael/pval.c b/res/ael/pval.c index 4245d42dbf..3ff806b8b5 100644 --- a/res/ael/pval.c +++ b/res/ael/pval.c @@ -49,6 +49,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") #ifdef AAL_ARGCHECK #include "asterisk/argdesc.h" #endif +#include "asterisk/utils.h" extern int localized_pbx_load_module(void); @@ -3702,7 +3703,7 @@ void add_extensions(struct ael_extension *exten) 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); } @@ -3782,7 +3783,7 @@ void add_extensions(struct ael_extension *exten) 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); } diff --git a/res/res_features.c b/res/res_features.c index 28cb0c3aa0..d0a177794a 100644 --- a/res/res_features.c +++ b/res/res_features.c @@ -498,7 +498,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou ast_clear_flag(peer, AST_FLAG_MASQ_NOSTREAM); } if (con) { - if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, ast_strdup(pu->parkingexten), ast_free, registrar)) + if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, ast_strdup(pu->parkingexten), ast_free_ptr, registrar)) notify_metermaids(pu->parkingexten, parking_con, AST_DEVICE_INUSE); } if (pu->notquiteyet) { @@ -2091,7 +2091,7 @@ static void *do_parking_thread(void *ignore) if (con) { char returnexten[AST_MAX_EXTENSION]; snprintf(returnexten, sizeof(returnexten), "%s,,t", peername); - ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", ast_strdup(returnexten), ast_free, registrar); + ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", ast_strdup(returnexten), ast_free_ptr, registrar); } if (comebacktoorigin) { set_c_e_p(chan, parking_con_dial, peername, 1);