diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-29 13:40:04 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-08-29 13:40:04 +0000 |
commit | e2d60aab8c861231fea834cd8bd76df4ce061dbf (patch) | |
tree | cbf72f71a114df5d507395b498aa21cdcbd40b40 /pbx | |
parent | c38db54e515ba7fc2a48d2c0363b92c1effca3cf (diff) |
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
........
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@41270 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rw-r--r-- | pbx/pbx_config.c | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c index 9916d4a30..dcfc4dcda 100644 --- a/pbx/pbx_config.c +++ b/pbx/pbx_config.c @@ -851,36 +851,31 @@ static int handle_save_dialplan(int fd, int argc, char *argv[]) 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); + char label[128]; + + tempdata = ast_strdupa(ast_get_extension_app_data(p)); - if (!tempdata) { /* XXX error duplicating string ? */ - incomplete = 1; - continue; - } - for (s = tempdata; *s; s++) + 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); } } } |