aboutsummaryrefslogtreecommitdiffstats
path: root/res/res_monitor.c
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-21 22:09:06 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-01-21 22:09:06 +0000
commit1e6b875c67de180e41374795555dde2859e23783 (patch)
treee352cdb4d3acb3dfdb89cf9a9ff83c30fe90ff94 /res/res_monitor.c
parentffcb98861ad5f7e0f3b246e264e61e2fa991522d (diff)
- conversions to allocation wrappers
- replace malloc/memset with ast_calloc - replace malloc/ast_copy_string with ast_strdup (based on patch from issue #6299) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8410 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'res/res_monitor.c')
-rw-r--r--res/res_monitor.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/res/res_monitor.c b/res/res_monitor.c
index 745f5cb45..9c154efb6 100644
--- a/res/res_monitor.c
+++ b/res/res_monitor.c
@@ -150,12 +150,10 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
}
}
- monitor = malloc(sizeof(struct ast_channel_monitor));
- if (!monitor) {
+ if (!(monitor = ast_calloc(1, sizeof(*monitor)))) {
UNLOCK_IF_NEEDED(&chan->lock, need_lock);
return -1;
}
- memset(monitor, 0, sizeof(struct ast_channel_monitor));
/* Determine file names */
if (!ast_strlen_zero(fname_base)) {
@@ -416,8 +414,8 @@ static int start_monitor_exec(struct ast_channel *chan, void *data)
if (urlprefix) {
snprintf(tmp,sizeof(tmp) - 1,"%s/%s.%s",urlprefix,fname_base,
((strcmp(format,"gsm")) ? "wav" : "gsm"));
- if (!chan->cdr)
- chan->cdr = ast_cdr_alloc();
+ if (!chan->cdr && !(chan->cdr = ast_cdr_alloc()))
+ return -1;
ast_cdr_setuserfield(chan, tmp);
}
if (waitforbridge) {
@@ -491,17 +489,15 @@ static int start_monitor_action(struct mansession *s, struct message *m)
}
if (ast_strlen_zero(fname)) {
- /* No filename base specified, default to channel name as per CLI */
- fname = malloc (FILENAME_MAX);
- if (!fname) {
+ /* No filename base specified, default to channel name as per CLI */
+ if (!(fname = ast_strdup(c->name))) {
astman_send_error(s, m, "Could not start monitoring channel");
ast_mutex_unlock(&c->lock);
return 0;
}
- memset(fname, 0, FILENAME_MAX);
- ast_copy_string(fname, c->name, FILENAME_MAX);
/* Channels have the format technology/channel_name - have to replace that / */
- if ((d=strchr(fname, '/'))) *d='-';
+ if ((d = strchr(fname, '/')))
+ *d = '-';
}
if (ast_monitor_start(c, format, fname, 1)) {