aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-07 15:19:13 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2006-05-07 15:19:13 +0000
commit6c10810c5650ea23647e61781cc44c4c854de2fe (patch)
tree601fd618ebac4c86fd99501d2e3ba64326b3dd35
parent623bf01f9a9eb3808803b7b309c8bf1c405a8c4a (diff)
- use ast_calloc instead of malloc+memset
- conver one malloc to ast_malloc git-svn-id: http://svn.digium.com/svn/asterisk/trunk@25356 f38db490-d61c-443f-a65b-d21fe96a405b
-rw-r--r--pbx/pbx_dundi.c17
1 files changed, 6 insertions, 11 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 12484412a..fedbd199d 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -758,9 +758,8 @@ static int dundi_answer_entity(struct dundi_transaction *trans, struct dundi_ies
}
totallen = sizeof(struct dundi_query_state);
totallen += (ies->eidcount - skipfirst) * sizeof(dundi_eid);
- st = malloc(totallen);
+ st = ast_calloc(1, totallen);
if (st) {
- memset(st, 0, totallen);
ast_copy_string(st->called_context, ies->called_context, sizeof(st->called_context));
memcpy(&st->reqeid, ies->reqeid, sizeof(st->reqeid));
st->trans = trans;
@@ -970,9 +969,8 @@ static int dundi_prop_precache(struct dundi_transaction *trans, struct dundi_ies
/* Prepare to run a query and then propagate that as necessary */
totallen += mapcount * sizeof(struct dundi_mapping);
totallen += (ies->eidcount - skipfirst) * sizeof(dundi_eid);
- st = malloc(totallen);
+ st = ast_calloc(1, totallen);
if (st) {
- memset(st, 0, totallen);
ast_copy_string(st->called_context, ies->called_context, sizeof(st->called_context));
ast_copy_string(st->called_number, ies->called_number, sizeof(st->called_number));
st->trans = trans;
@@ -1057,9 +1055,8 @@ static int dundi_answer_query(struct dundi_transaction *trans, struct dundi_ies
totallen += mapcount * sizeof(struct dundi_mapping);
totallen += (ies->eidcount - skipfirst) * sizeof(dundi_eid);
- st = malloc(totallen);
+ st = ast_calloc(1, totallen);
if (st) {
- memset(st, 0, totallen);
ast_copy_string(st->called_context, ies->called_context, sizeof(st->called_context));
ast_copy_string(st->called_number, ies->called_number, sizeof(st->called_number));
st->trans = trans;
@@ -2740,9 +2737,8 @@ static struct dundi_transaction *create_transaction(struct dundi_peer *p)
tid = get_trans_id();
if (tid < 1)
return NULL;
- trans = malloc(sizeof(struct dundi_transaction));
+ trans = ast_calloc(1, sizeof(*trans));
if (trans) {
- memset(trans, 0, sizeof(struct dundi_transaction));
if (global_storehistory) {
trans->start = ast_tvnow();
ast_set_flag(trans, FLAG_STOREHIST);
@@ -2835,7 +2831,7 @@ static void destroy_trans(struct dundi_transaction *trans, int fromtimeout)
}
}
peer->lookuptimes[0] = ast_tvdiff_ms(ast_tvnow(), trans->start);
- peer->lookups[0] = malloc(strlen(trans->parent->number) + strlen(trans->parent->dcontext) + 2);
+ peer->lookups[0] = ast_malloc(strlen(trans->parent->number) + strlen(trans->parent->dcontext) + 2);
if (peer->lookups[0]) {
sprintf(peer->lookups[0], "%s@%s", trans->parent->number, trans->parent->dcontext);
peer->avgms += peer->lookuptimes[0];
@@ -2907,9 +2903,8 @@ static int dundi_send(struct dundi_transaction *trans, int cmdresp, int flags, i
/* Reserve enough space for encryption */
if (ast_test_flag(trans, FLAG_ENCRYPT))
len += 384;
- pack = malloc(len);
+ pack = ast_calloc(1, len);
if (pack) {
- memset(pack, 0, len);
pack->h = (struct dundi_hdr *)(pack->data);
if (cmdresp != DUNDI_COMMAND_ACK) {
pack->retransid = ast_sched_add(sched, trans->retranstimer, dundi_rexmit, pack);