[asterisk-commits] russell: trunk r41270 - in /trunk: ./
pbx/pbx_config.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Aug 29 06:40:05 MST 2006
Author: russell
Date: Tue Aug 29 08:40:04 2006
New Revision: 41270
URL: http://svn.digium.com/view/asterisk?rev=41270&view=rev
Log:
Merged revisions 41269 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.2
........
r41269 | russell | 2006-08-29 09:33:34 -0400 (Tue, 29 Aug 2006) | 3 lines
clean up last commit ... most notably, there is no reason to do heap
allocations here, and it also included a potential memory leak
........
Modified:
trunk/ (props changed)
trunk/pbx/pbx_config.c
Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.
Modified: trunk/pbx/pbx_config.c
URL: http://svn.digium.com/view/asterisk/trunk/pbx/pbx_config.c?rev=41270&r1=41269&r2=41270&view=diff
==============================================================================
--- trunk/pbx/pbx_config.c (original)
+++ trunk/pbx/pbx_config.c Tue Aug 29 08:40:04 2006
@@ -851,36 +851,31 @@
ast_get_extension_app(p));
} else { /* copy and replace '|' with ',' */
const char *sep, *cid;
- char *tempdata = strdup(ast_get_extension_app_data(p));
+ char *tempdata;
char *s;
const char *el = ast_get_extension_label(p);
- char *label = calloc(1, 128);
-
- if (!tempdata) { /* XXX error duplicating string ? */
- incomplete = 1;
- continue;
- }
- for (s = tempdata; *s; s++)
+ char label[128];
+
+ tempdata = ast_strdupa(ast_get_extension_app_data(p));
+
+ for (s = tempdata; *s; s++) {
if (*s == '|')
*s = ',';
+ }
+
if (ast_get_extension_matchcid(p)) {
sep = "/";
cid = ast_get_extension_cidmatch(p);
- } else {
+ } else
sep = cid = "";
- }
- if (el) {
- if (snprintf(label, 127, "(%s)", el) != (strlen(el)+2)) {
- incomplete = 1; /* error encountered or label > 125 chars */
- label = NULL;
- };
- };
+
+ if (el && (snprintf(label, 127, "(%s)", el) != (strlen(el) + 2)))
+ incomplete = 1; /* error encountered or label > 125 chars */
+
fprintf(output, "exten => %s%s%s,%d%s,%s(%s)\n",
ast_get_extension_name(p), sep, cid,
- ast_get_extension_priority(p), (label)?label:"",
+ ast_get_extension_priority(p), label,
ast_get_extension_app(p), tempdata);
- free(tempdata);
- if (label) free(label);
}
}
}
More information about the asterisk-commits
mailing list