diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-13 18:38:55 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-13 18:38:55 +0000 |
commit | c68a2d2d8eeae4700c5d8aca778baebd63261010 (patch) | |
tree | 5a94467aed03520611a253029bd57ee366f338e5 /apps | |
parent | f94feca2c56f917573ddbfe2138f3cc6bb6e30fa (diff) |
Various cleanups from comments in an email from Luigi Rizzo. Thank you!
- Use a cleaner syntax for declaring the allocation macros
- Fix return value for ast_strdup/ast_strndup
- remove safe_strdup from app_macro, since ast_strup does the same thing
- fix a place in app_queue where ast_calloc+strncpy was used instead of
ast_strdup. If you are helping out with these conversions, please watch out
for other places where this is done.
- add a note to the coding guidelines about the fix to app_queue
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8065 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps')
-rw-r--r-- | apps/app_macro.c | 13 | ||||
-rw-r--r-- | apps/app_queue.c | 3 |
2 files changed, 5 insertions, 11 deletions
diff --git a/apps/app_macro.c b/apps/app_macro.c index 4b88e1594..63cf46474 100644 --- a/apps/app_macro.c +++ b/apps/app_macro.c @@ -89,11 +89,6 @@ STANDARD_LOCAL_USER; LOCAL_USER_DECL; -static char *safe_strdup(const char *s) -{ - return s ? strdup(s) : NULL; -} - static int macro_exec(struct ast_channel *chan, void *data) { const char *s; @@ -169,17 +164,17 @@ static int macro_exec(struct ast_channel *chan, void *data) } argc = 1; /* Save old macro variables */ - save_macro_exten = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_EXTEN")); + save_macro_exten = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_EXTEN")); pbx_builtin_setvar_helper(chan, "MACRO_EXTEN", oldexten); - save_macro_context = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT")); + save_macro_context = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_CONTEXT")); pbx_builtin_setvar_helper(chan, "MACRO_CONTEXT", oldcontext); - save_macro_priority = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY")); + save_macro_priority = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_PRIORITY")); snprintf(pc, sizeof(pc), "%d", oldpriority); pbx_builtin_setvar_helper(chan, "MACRO_PRIORITY", pc); - save_macro_offset = safe_strdup(pbx_builtin_getvar_helper(chan, "MACRO_OFFSET")); + save_macro_offset = ast_strdup(pbx_builtin_getvar_helper(chan, "MACRO_OFFSET")); pbx_builtin_setvar_helper(chan, "MACRO_OFFSET", NULL); /* Setup environment for new run */ diff --git a/apps/app_queue.c b/apps/app_queue.c index 669e25d86..06aebe724 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -1709,8 +1709,7 @@ static struct localuser *wait_for_answer(struct queue_ent *qe, struct localuser if (in->cid.cid_ani) { if (o->chan->cid.cid_ani) free(o->chan->cid.cid_ani); - if ((o->chan->cid.cid_ani = ast_calloc(1, strlen(in->cid.cid_ani) + 1))) - strncpy(o->chan->cid.cid_ani, in->cid.cid_ani, strlen(in->cid.cid_ani) + 1); + o->chan->cid.cid_ani = ast_strdup(in->cid.cid_ani); } if (o->chan->cid.cid_rdnis) free(o->chan->cid.cid_rdnis); |