dect
/
asterisk
Archived
13
0
Fork 0

Convert uses of strdup() to ast_strdup()

(issue #9983, eliel)


git-svn-id: http://svn.digium.com/svn/asterisk/trunk@69436 f38db490-d61c-443f-a65b-d21fe96a405b
This commit is contained in:
russell 2007-06-14 23:01:01 +00:00
parent e95289a0e9
commit 7a0fe5c93f
19 changed files with 62 additions and 62 deletions

View File

@ -444,7 +444,7 @@ static int do_directory(struct ast_channel *chan, struct ast_config *cfg, struct
/* Find all candidate extensions */
while(v) {
/* Find a candidate extension */
start = strdup(v->value);
start = ast_strdup(v->value);
if (start && !strcasestr(start, "hidefromdir=yes")) {
stringp=start;
strsep(&stringp, ",");

View File

@ -984,7 +984,7 @@ static char *complete_meetmecmd(const char *line, const char *word, int pos, int
/* User Number || Conf Command option*/
if (strstr(line, "mute") || strstr(line, "kick")) {
if (state == 0 && (strstr(line, "kick") || strstr(line,"mute")) && !strncasecmp(word, "all", len))
return strdup("all");
return ast_strdup("all");
which++;
AST_LIST_LOCK(&confs);
@ -1009,9 +1009,9 @@ static char *complete_meetmecmd(const char *line, const char *word, int pos, int
}
}
AST_LIST_UNLOCK(&confs);
return usr ? strdup(usrno) : NULL;
return usr ? ast_strdup(usrno) : NULL;
} else if ( strstr(line, "list") && ( 0 == state ) )
return strdup("concise");
return ast_strdup("concise");
}
return NULL;

View File

@ -2333,7 +2333,7 @@ static char *message_template_parse_filebody(char *filename) {
static char *message_template_parse_emailbody(const char *configuration)
{
char *tmpread, *tmpwrite;
char *emailbody = strdup(configuration);
char *emailbody = ast_strdup(configuration);
/* substitute strings \t and \n into the apropriate characters */
tmpread = tmpwrite = emailbody;
@ -2678,12 +2678,12 @@ static char *complete_minivm_show_users(const char *line, const char *word, int
if (pos > 4)
return NULL;
if (pos == 3)
return (state == 0) ? strdup("for") : NULL;
return (state == 0) ? ast_strdup("for") : NULL;
wordlen = strlen(word);
AST_LIST_TRAVERSE(&minivm_accounts, vmu, list) {
if (!strncasecmp(word, vmu->domain, wordlen)) {
if (domain && strcmp(domain, vmu->domain) && ++which > state)
return strdup(vmu->domain);
return ast_strdup(vmu->domain);
/* ignore repeated domains ? */
domain = vmu->domain;
}

View File

@ -515,7 +515,7 @@ static int speech_processing_sound(struct ast_channel *chan, void *data)
speech->processing_sound = NULL;
}
speech->processing_sound = strdup(data);
speech->processing_sound = ast_strdup(data);
ast_module_user_remove(u);
@ -747,8 +747,8 @@ static int speech_background(struct ast_channel *chan, void *data)
speech->results = ast_calloc(1, sizeof(*speech->results));
if (speech->results != NULL) {
speech->results->score = 1000;
speech->results->text = strdup(dtmf);
speech->results->grammar = strdup("dtmf");
speech->results->text = ast_strdup(dtmf);
speech->results->grammar = ast_strdup("dtmf");
}
}

View File

@ -536,7 +536,7 @@ static int oh323_digit_begin(struct ast_channel *c, char digit)
ast_log(LOG_DTMF, "Begin sending inband digit %c on %s\n", digit, c->name);
}
pvt->txDtmfDigit = digit;
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
token = pvt->cd.call_token ? ast_strdup(pvt->cd.call_token) : NULL;
ast_mutex_unlock(&pvt->lock);
h323_send_tone(token, digit);
if (token) {
@ -575,7 +575,7 @@ static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int durat
ast_log(LOG_DTMF, "End sending inband digit %c on %s, duration %d\n", digit, c->name, duration);
}
pvt->txDtmfDigit = ' ';
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
token = pvt->cd.call_token ? ast_strdup(pvt->cd.call_token) : NULL;
ast_mutex_unlock(&pvt->lock);
h323_send_tone(token, ' ');
if (token) {
@ -680,7 +680,7 @@ static int oh323_answer(struct ast_channel *c)
ast_debug(1, "Answering on %s\n", c->name);
ast_mutex_lock(&pvt->lock);
token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
token = pvt->cd.call_token ? ast_strdup(pvt->cd.call_token) : NULL;
ast_mutex_unlock(&pvt->lock);
res = h323_answering_call(token, 0);
if (token)
@ -739,7 +739,7 @@ static int oh323_hangup(struct ast_channel *c)
/* Start the process if it's not already started */
if (!pvt->alreadygone && !pvt->hangupcause) {
call_token = pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL;
call_token = pvt->cd.call_token ? ast_strdup(pvt->cd.call_token) : NULL;
if (call_token) {
/* Release lock to eliminate deadlock */
ast_mutex_unlock(&pvt->lock);
@ -877,7 +877,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
int got_progress;
ast_mutex_lock(&pvt->lock);
token = (pvt->cd.call_token ? strdup(pvt->cd.call_token) : NULL);
token = (pvt->cd.call_token ? ast_strdup(pvt->cd.call_token) : NULL);
got_progress = pvt->got_progress;
if (condition == AST_CONTROL_PROGRESS)
pvt->got_progress = 1;
@ -1092,7 +1092,7 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
ch->cid.cid_ton = pvt->cd.type_of_number;
if (!ast_strlen_zero(pvt->exten) && strcmp(pvt->exten, "s")) {
ch->cid.cid_dnid = strdup(pvt->exten);
ch->cid.cid_dnid = ast_strdup(pvt->exten);
}
if (pvt->cd.transfer_capability >= 0)
ch->transfercapability = pvt->cd.transfer_capability;

View File

@ -1409,7 +1409,7 @@ static char *complete_ch_helper(const char *line, const char *word, int pos, int
ast_mutex_unlock(&c->lock);
}
if (c) {
ret = strdup(c->name);
ret = ast_strdup(c->name);
ast_mutex_unlock(&c->lock);
} else
ret = NULL;
@ -1429,13 +1429,13 @@ static char *complete_debug_port (const char *line, const char *word, int pos, i
switch (pos) {
case 4:
if (*word == 'p')
return strdup("port");
return ast_strdup("port");
else if (*word == 'o')
return strdup("only");
return ast_strdup("only");
break;
case 6:
if (*word == 'o')
return strdup("only");
return ast_strdup("only");
break;
}
return NULL;
@ -1452,15 +1452,15 @@ static char *complete_show_config (const char *line, const char *word, int pos,
switch (pos) {
case 3:
if ((!strncmp(word, "description", wordlen)) && (++which > state))
return strdup("description");
return ast_strdup("description");
if ((!strncmp(word, "descriptions", wordlen)) && (++which > state))
return strdup("descriptions");
return ast_strdup("descriptions");
if ((!strncmp(word, "0", wordlen)) && (++which > state))
return strdup("0");
return ast_strdup("0");
while ((port = misdn_cfg_get_next_port(port)) != -1) {
snprintf(buffer, sizeof(buffer), "%d", port);
if ((!strncmp(word, buffer, wordlen)) && (++which > state)) {
return strdup(buffer);
return ast_strdup(buffer);
}
}
break;
@ -1472,14 +1472,14 @@ static char *complete_show_config (const char *line, const char *word, int pos,
misdn_cfg_get_name(elem, buffer, sizeof(buffer));
if (!wordlen || !strncmp(word, buffer, wordlen)) {
if (++which > state)
return strdup(buffer);
return ast_strdup(buffer);
}
}
} else if (strstr(line, "descriptions ")) {
if ((!wordlen || !strncmp(word, "general", wordlen)) && (++which > state))
return strdup("general");
return ast_strdup("general");
if ((!wordlen || !strncmp(word, "ports", wordlen)) && (++which > state))
return strdup("ports");
return ast_strdup("ports");
}
break;
}
@ -1895,7 +1895,7 @@ static int read_config(struct chan_list *ch, int orig)
if ( !ast_strlen_zero(bc->rad) ) {
if (ast->cid.cid_rdnis)
ast_free(ast->cid.cid_rdnis);
ast->cid.cid_rdnis = strdup(bc->rad);
ast->cid.cid_rdnis = ast_strdup(bc->rad);
}
misdn_cfg_get(bc->port, MISDN_CFG_OVERLAP_DIAL, &ch->overlap_dial, sizeof(ch->overlap_dial));

View File

@ -688,8 +688,8 @@ static void get_callerid(struct vpb_pvt *p)
if (cli_struct->ra_cldn[0]=='\0'){
/*
owner->cid.cid_num = strdup(cli_struct->cldn);
owner->cid.cid_name = strdup(cli_struct->cn);
owner->cid.cid_num = ast_strdup(cli_struct->cldn);
owner->cid.cid_name = ast_strdup(cli_struct->cn);
*/
if (owner){
ast_set_callerid(owner, cli_struct->cldn, cli_struct->cn, cli_struct->cldn);
@ -2694,7 +2694,7 @@ static struct ast_channel *vpb_request(const char *type, int format, void *data,
int oldformat;
struct vpb_pvt *p;
struct ast_channel *tmp = NULL;
char *name = strdup(data ? (char *)data : "");
char *name = ast_strdup(data ? (char *)data : "");
char *s, *sepstr;
int group=-1;
@ -2940,7 +2940,7 @@ int load_module()
} else if (strcasecmp(v->name, "language") == 0) {
strncpy(language, v->value, sizeof(language)-1);
} else if (strcasecmp(v->name, "callerid") == 0) {
callerid = strdup(v->value);
callerid = ast_strdup(v->value);
} else if (strcasecmp(v->name, "mode") == 0) {
if (strncasecmp(v->value, "di", 2) == 0)
mode = MODE_DIALTONE;

View File

@ -169,7 +169,7 @@ char *iax_prov_complete_template(const char *line, const char *word, int pos, in
ast_mutex_lock(&provlock);
for (c = templates; c; c = c->next) {
if (!strncasecmp(word, c->name, wordlen) && ++which > state) {
ret = strdup(c->name);
ret = ast_strdup(c->name);
break;
}
}

View File

@ -1980,7 +1980,7 @@ static char **ast_el_strtoarr(char *buf)
}
}
match_list[matches++] = strdup(retstr);
match_list[matches++] = ast_strdup(retstr);
}
if (!match_list)

View File

@ -295,7 +295,7 @@ static char *complete_channeltypes(const char *line, const char *word, int pos,
AST_LIST_TRAVERSE(&backends, cl, list) {
if (!strncasecmp(word, cl->tech->type, wordlen) && ++which > state) {
ret = strdup(cl->tech->type);
ret = ast_strdup(cl->tech->type);
break;
}
}

View File

@ -105,7 +105,7 @@ static char *complete_fn(const char *word, int state)
if (c && word[0] != '/')
c += (strlen(ast_config_AST_MODULE_DIR) + 1);
return c ? strdup(c) : c;
return c ? ast_strdup(c) : c;
}
static char *handle_load(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
@ -693,7 +693,7 @@ static char *handle_core_set_debug_channel(struct ast_cli_entry *e, int cmd, str
/* XXX remember to handle the optional "off" */
if (a->pos != e->args)
return NULL;
return a->n == 0 ? strdup("all") : ast_complete_channels(a->line, a->word, a->pos, a->n - 1, e->args);
return a->n == 0 ? ast_strdup("all") : ast_complete_channels(a->line, a->word, a->pos, a->n - 1, e->args);
}
/* 'core set debug channel {all|chan_id}' */
if (a->argc == e->args + 2) {
@ -1027,7 +1027,7 @@ static int set_full_cmd(struct ast_cli_entry *e)
char buf[80];
ast_join(buf, sizeof(buf), e->cmda);
e->_full_cmd = strdup(buf);
e->_full_cmd = ast_strdup(buf);
if (!e->_full_cmd) {
ast_log(LOG_WARNING, "-- cannot allocate <%s>\n", buf);
return -1;
@ -1144,7 +1144,7 @@ static char *is_prefix(const char *word, const char *token,
if (strncasecmp(token, word, lw)) /* no match */
return NULL;
*actual = 1;
return (pos != 0) ? NULL : strdup(token);
return (pos != 0) ? NULL : ast_strdup(token);
}
/* now handle regexp match */
@ -1158,7 +1158,7 @@ static char *is_prefix(const char *word, const char *token,
continue;
(*actual)++;
if (pos-- == 0)
return strdup(s);
return ast_strdup(s);
}
return NULL;
}

View File

@ -345,8 +345,8 @@ static int enum_callback(void *context, unsigned char *answer, int len, unsigned
if ((p = ast_realloc(c->naptr_rrs, sizeof(*c->naptr_rrs) * (c->naptr_rrs_count + 1)))) {
c->naptr_rrs = p;
memcpy(&c->naptr_rrs[c->naptr_rrs_count].naptr, answer, sizeof(c->naptr_rrs->naptr));
c->naptr_rrs[c->naptr_rrs_count].result = strdup(c->dst);
c->naptr_rrs[c->naptr_rrs_count].tech = strdup(c->tech);
c->naptr_rrs[c->naptr_rrs_count].result = ast_strdup(c->dst);
c->naptr_rrs[c->naptr_rrs_count].tech = ast_strdup(c->tech);
c->naptr_rrs[c->naptr_rrs_count].sort_pos = c->naptr_rrs_count;
c->naptr_rrs_count++;
}

View File

@ -839,7 +839,7 @@ struct ast_filestream *ast_readfile(const char *filename, const char *type, cons
fs->fmt = f;
fs->flags = flags;
fs->mode = mode;
fs->filename = strdup(filename);
fs->filename = ast_strdup(filename);
fs->vfs = NULL;
break;
}
@ -950,11 +950,11 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
fs->flags = flags;
fs->mode = mode;
if (orig_fn) {
fs->realfilename = strdup(orig_fn);
fs->filename = strdup(fn);
fs->realfilename = ast_strdup(orig_fn);
fs->filename = ast_strdup(fn);
} else {
fs->realfilename = NULL;
fs->filename = strdup(filename);
fs->filename = ast_strdup(filename);
}
fs->vfs = NULL;
/* If truncated, we'll be at the beginning; if not truncated, then append */

View File

@ -215,12 +215,12 @@ static struct ast_str *static_callback(struct sockaddr_in *req, const char *uri,
out404:
*status = 404;
*title = strdup("Not Found");
*title = ast_strdup("Not Found");
return ast_http_error(404, "Not Found", NULL, "Nothing to see here. Move along.");
out403:
*status = 403;
*title = strdup("Access Denied");
*title = ast_strdup("Access Denied");
return ast_http_error(403, "Access Denied", NULL, "Sorry, I cannot let you do that, Dave.");
}
@ -616,7 +616,7 @@ static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *statu
out = ast_http_error(302, "Moved Temporarily", buf,
"There is no spoon...");
*status = 302;
*title = strdup("Moved Temporarily");
*title = ast_strdup("Moved Temporarily");
break;
}
}
@ -655,7 +655,7 @@ static struct ast_str *handle_uri(struct sockaddr_in *sin, char *uri, int *statu
out = ast_http_error(404, "Not Found", NULL,
"The requested URL was not found on this server.");
*status = 404;
*title = strdup("Not Found");
*title = ast_strdup("Not Found");
}
cleanup:

View File

@ -526,7 +526,7 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state,
if (!strncasecmp(word, cur->resource, l) &&
(cur->info->reload || !needsreload) &&
++which > state) {
ret = strdup(cur->resource);
ret = ast_strdup(cur->resource);
break;
}
}
@ -535,7 +535,7 @@ char *ast_module_helper(const char *line, const char *word, int pos, int state,
if (!ret) {
for (i=0; !ret && reload_classes[i].name; i++) {
if (!strncasecmp(word, reload_classes[i].name, l) && ++which > state)
ret = strdup(reload_classes[i].name);
ret = ast_strdup(reload_classes[i].name);
}
}

View File

@ -1360,7 +1360,7 @@ static char *complete_show_function(const char *line, const char *word, int pos,
AST_RWLIST_RDLOCK(&acf_root);
AST_RWLIST_TRAVERSE(&acf_root, acf, acflist) {
if (!strncasecmp(word, acf->name, wordlen) && ++which > state) {
ret = strdup(acf->name);
ret = ast_strdup(acf->name);
break;
}
}
@ -3066,7 +3066,7 @@ static char *complete_show_application(const char *line, const char *word, int p
AST_RWLIST_RDLOCK(&apps);
AST_RWLIST_TRAVERSE(&apps, a, list) {
if (!strncasecmp(word, a->name, wordlen) && ++which > state) {
ret = strdup(a->name);
ret = ast_strdup(a->name);
break;
}
}

View File

@ -469,7 +469,7 @@ int ast_park_call(struct ast_channel *chan, struct ast_channel *peer, int timeou
if (!con) /* Still no context? Bad */
ast_log(LOG_ERROR, "Parking context '%s' does not exist and unable to create\n", parking_con);
else { /* Add extension to context */
if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, strdup(pu->parkingexten), ast_free, registrar))
if (!ast_add_extension2(con, 1, pu->parkingexten, 1, NULL, NULL, parkedcall, ast_strdup(pu->parkingexten), ast_free, registrar))
notify_metermaids(pu->parkingexten, parking_con);
}
/* Tell the peer channel the number of the parking space */
@ -1937,7 +1937,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", strdup(returnexten), ast_free, registrar);
ast_add_extension2(con, 1, peername, 1, NULL, NULL, "Dial", ast_strdup(returnexten), ast_free, registrar);
}
if (comebacktoorigin) {
set_c_e_p(chan, parking_con_dial, peername, 1);

View File

@ -314,8 +314,8 @@ static int ind_load_module(void)
return -1;
}
ts->next = NULL;
ts->name = strdup(v->name);
ts->data = strdup(v->value);
ts->name = ast_strdup(v->name);
ts->data = ast_strdup(v->value);
if (ps)
ps->next = ts;
else

View File

@ -154,7 +154,7 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
int directory = strchr(fname_base, '/') ? 1 : 0;
/* try creating the directory just in case it doesn't exist */
if (directory) {
char *name = strdup(fname_base);
char *name = ast_strdup(fname_base);
snprintf(tmp, sizeof(tmp), "mkdir -p \"%s\"",dirname(name));
ast_free(name);
ast_safe_system(tmp);
@ -186,9 +186,9 @@ int ast_monitor_start( struct ast_channel *chan, const char *format_spec,
/* Determine file format */
if (!ast_strlen_zero(format_spec)) {
monitor->format = strdup(format_spec);
monitor->format = ast_strdup(format_spec);
} else {
monitor->format = strdup("wav");
monitor->format = ast_strdup("wav");
}
/* open files */
@ -366,7 +366,7 @@ int ast_monitor_change_fname(struct ast_channel *chan, const char *fname_base, i
int directory = strchr(fname_base, '/') ? 1 : 0;
/* try creating the directory just in case it doesn't exist */
if (directory) {
char *name = strdup(fname_base);
char *name = ast_strdup(fname_base);
snprintf(tmp, sizeof(tmp), "mkdir -p %s",dirname(name));
ast_free(name);
ast_safe_system(tmp);