mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-12 15:45:18 +00:00
ast_calloc janitor (Inspired by issue 9860)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@66981 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -387,7 +387,7 @@ static int features_hangup(struct ast_channel *ast)
|
||||
ast_hangup(p->subchan);
|
||||
ast_mutex_unlock(&p->lock);
|
||||
ast_mutex_destroy(&p->lock);
|
||||
free(p);
|
||||
ast_free(p);
|
||||
return 0;
|
||||
}
|
||||
ast_mutex_unlock(&p->lock);
|
||||
@@ -428,9 +428,8 @@ static struct feature_pvt *features_alloc(char *data, int format)
|
||||
ast_log(LOG_NOTICE, "Unable to allocate subchannel '%s/%s'\n", tech, dest);
|
||||
return NULL;
|
||||
}
|
||||
tmp = malloc(sizeof(struct feature_pvt));
|
||||
tmp = ast_calloc(1, sizeof(*tmp));
|
||||
if (tmp) {
|
||||
memset(tmp, 0, sizeof(struct feature_pvt));
|
||||
for (x=0;x<3;x++)
|
||||
init_sub(tmp->subs + x);
|
||||
ast_mutex_init(&tmp->lock);
|
||||
@@ -461,7 +460,7 @@ static struct ast_channel *features_new(struct feature_pvt *p, int state, int in
|
||||
/* figure out what you want the name to be */
|
||||
for (x=1;x<4;x++) {
|
||||
if (b2)
|
||||
free(b2);
|
||||
ast_free(b2);
|
||||
asprintf(&b2, "%s/%s-%d", p->tech, p->dest, x);
|
||||
for (y=0;y<3;y++) {
|
||||
if (y == index)
|
||||
@@ -475,7 +474,7 @@ static struct ast_channel *features_new(struct feature_pvt *p, int state, int in
|
||||
tmp = ast_channel_alloc(0, state, 0,0, "", "", "", 0, "Feature/%s", b2);
|
||||
/* free up the name, it was copied into the channel name */
|
||||
if (b2)
|
||||
free(b2);
|
||||
ast_free(b2);
|
||||
if (!tmp) {
|
||||
ast_log(LOG_WARNING, "Unable to allocate channel structure\n");
|
||||
return NULL;
|
||||
@@ -566,7 +565,7 @@ static int unload_module(void)
|
||||
if (p->owner)
|
||||
ast_softhangup(p->owner, AST_SOFTHANGUP_APPUNLOAD);
|
||||
AST_LIST_REMOVE_CURRENT(&features, list);
|
||||
free(p);
|
||||
ast_free(p);
|
||||
}
|
||||
AST_LIST_TRAVERSE_SAFE_END
|
||||
AST_LIST_UNLOCK(&features);
|
||||
|
@@ -881,7 +881,7 @@ static struct gtalk_pvt *gtalk_alloc(struct gtalk *client, const char *us, const
|
||||
tmp->parent = client;
|
||||
if (!tmp->rtp) {
|
||||
ast_log(LOG_WARNING, "Out of RTP sessions?\n");
|
||||
free(tmp);
|
||||
ast_free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -1600,8 +1600,7 @@ static struct gtalk_candidate *gtalk_create_candidate(char *args)
|
||||
{
|
||||
char *name, *type, *preference, *protocol;
|
||||
struct gtalk_candidate *res;
|
||||
res = malloc(sizeof(struct gtalk_candidate));
|
||||
memset(res, 0, sizeof(struct gtalk_candidate));
|
||||
res = ast_calloc(1, sizeof(*res));
|
||||
if (args)
|
||||
name = args;
|
||||
if ((args = strchr(args, ','))) {
|
||||
@@ -1758,8 +1757,7 @@ static int gtalk_load_config(void)
|
||||
while (cat) {
|
||||
if (strcasecmp(cat, "general")) {
|
||||
var = ast_variable_browse(cfg, cat);
|
||||
member = (struct gtalk *) malloc(sizeof(struct gtalk));
|
||||
memset(member, 0, sizeof(struct gtalk));
|
||||
member = ast_calloc(1, sizeof(*member));
|
||||
ASTOBJ_INIT(member);
|
||||
ASTOBJ_WRLOCK(member);
|
||||
if (!strcasecmp(cat, "guest")) {
|
||||
|
@@ -288,7 +288,7 @@ static void oh323_destroy_alias(struct oh323_alias *alias)
|
||||
{
|
||||
if (h323debug)
|
||||
ast_log(LOG_DEBUG, "Destroying alias '%s'\n", alias->name);
|
||||
free(alias);
|
||||
ast_free(alias);
|
||||
}
|
||||
|
||||
static void oh323_destroy_user(struct oh323_user *user)
|
||||
@@ -296,7 +296,7 @@ static void oh323_destroy_user(struct oh323_user *user)
|
||||
if (h323debug)
|
||||
ast_log(LOG_DEBUG, "Destroying user '%s'\n", user->name);
|
||||
ast_free_ha(user->ha);
|
||||
free(user);
|
||||
ast_free(user);
|
||||
}
|
||||
|
||||
static void oh323_destroy_peer(struct oh323_peer *peer)
|
||||
@@ -304,7 +304,7 @@ static void oh323_destroy_peer(struct oh323_peer *peer)
|
||||
if (h323debug)
|
||||
ast_log(LOG_DEBUG, "Destroying peer '%s'\n", peer->name);
|
||||
ast_free_ha(peer->ha);
|
||||
free(peer);
|
||||
ast_free(peer);
|
||||
}
|
||||
|
||||
static int oh323_simulate_dtmf_end(void *data)
|
||||
@@ -419,35 +419,35 @@ static void oh323_update_info(struct ast_channel *c)
|
||||
static void cleanup_call_details(call_details_t *cd)
|
||||
{
|
||||
if (cd->call_token) {
|
||||
free(cd->call_token);
|
||||
ast_free(cd->call_token);
|
||||
cd->call_token = NULL;
|
||||
}
|
||||
if (cd->call_source_aliases) {
|
||||
free(cd->call_source_aliases);
|
||||
ast_free(cd->call_source_aliases);
|
||||
cd->call_source_aliases = NULL;
|
||||
}
|
||||
if (cd->call_dest_alias) {
|
||||
free(cd->call_dest_alias);
|
||||
ast_free(cd->call_dest_alias);
|
||||
cd->call_dest_alias = NULL;
|
||||
}
|
||||
if (cd->call_source_name) {
|
||||
free(cd->call_source_name);
|
||||
ast_free(cd->call_source_name);
|
||||
cd->call_source_name = NULL;
|
||||
}
|
||||
if (cd->call_source_e164) {
|
||||
free(cd->call_source_e164);
|
||||
ast_free(cd->call_source_e164);
|
||||
cd->call_source_e164 = NULL;
|
||||
}
|
||||
if (cd->call_dest_e164) {
|
||||
free(cd->call_dest_e164);
|
||||
ast_free(cd->call_dest_e164);
|
||||
cd->call_dest_e164 = NULL;
|
||||
}
|
||||
if (cd->sourceIp) {
|
||||
free(cd->sourceIp);
|
||||
ast_free(cd->sourceIp);
|
||||
cd->sourceIp = NULL;
|
||||
}
|
||||
if (cd->redirect_number) {
|
||||
free(cd->redirect_number);
|
||||
ast_free(cd->redirect_number);
|
||||
cd->redirect_number = NULL;
|
||||
}
|
||||
}
|
||||
@@ -496,7 +496,7 @@ static void __oh323_destroy(struct oh323_pvt *pvt)
|
||||
} else {
|
||||
ast_mutex_unlock(&pvt->lock);
|
||||
ast_mutex_destroy(&pvt->lock);
|
||||
free(pvt);
|
||||
ast_free(pvt);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -540,7 +540,7 @@ static int oh323_digit_begin(struct ast_channel *c, char digit)
|
||||
ast_mutex_unlock(&pvt->lock);
|
||||
h323_send_tone(token, digit);
|
||||
if (token) {
|
||||
free(token);
|
||||
ast_free(token);
|
||||
}
|
||||
} else
|
||||
ast_mutex_unlock(&pvt->lock);
|
||||
@@ -579,7 +579,7 @@ static int oh323_digit_end(struct ast_channel *c, char digit, unsigned int durat
|
||||
ast_mutex_unlock(&pvt->lock);
|
||||
h323_send_tone(token, ' ');
|
||||
if (token) {
|
||||
free(token);
|
||||
ast_free(token);
|
||||
}
|
||||
}
|
||||
oh323_update_info(c);
|
||||
@@ -684,7 +684,7 @@ static int oh323_answer(struct ast_channel *c)
|
||||
ast_mutex_unlock(&pvt->lock);
|
||||
res = h323_answering_call(token, 0);
|
||||
if (token)
|
||||
free(token);
|
||||
ast_free(token);
|
||||
|
||||
oh323_update_info(c);
|
||||
if (c->_state != AST_STATE_UP) {
|
||||
@@ -746,7 +746,7 @@ static int oh323_hangup(struct ast_channel *c)
|
||||
if (h323_clear_call(call_token, q931cause)) {
|
||||
ast_log(LOG_WARNING, "ClearCall failed.\n");
|
||||
}
|
||||
free(call_token);
|
||||
ast_free(call_token);
|
||||
ast_mutex_lock(&pvt->lock);
|
||||
}
|
||||
}
|
||||
@@ -939,7 +939,7 @@ static int oh323_indicate(struct ast_channel *c, int condition, const void *data
|
||||
if (h323debug)
|
||||
ast_log(LOG_DEBUG, "OH323: Indicated %d on %s, res=%d\n", condition, token, res);
|
||||
if (token)
|
||||
free(token);
|
||||
ast_free(token);
|
||||
oh323_update_info(c);
|
||||
|
||||
return res;
|
||||
@@ -1113,23 +1113,22 @@ static struct oh323_pvt *oh323_alloc(int callid)
|
||||
{
|
||||
struct oh323_pvt *pvt;
|
||||
|
||||
pvt = (struct oh323_pvt *) malloc(sizeof(struct oh323_pvt));
|
||||
pvt = ast_calloc(1, sizeof(*pvt));
|
||||
if (!pvt) {
|
||||
ast_log(LOG_ERROR, "Couldn't allocate private structure. This is bad\n");
|
||||
return NULL;
|
||||
}
|
||||
memset(pvt, 0, sizeof(struct oh323_pvt));
|
||||
pvt->cd.redirect_reason = -1;
|
||||
pvt->cd.transfer_capability = -1;
|
||||
/* Ensure the call token is allocated for outgoing call */
|
||||
if (!callid) {
|
||||
if ((pvt->cd).call_token == NULL) {
|
||||
(pvt->cd).call_token = (char *)malloc(128);
|
||||
(pvt->cd).call_token = ast_calloc(1, 128);
|
||||
}
|
||||
if (!pvt->cd.call_token) {
|
||||
ast_log(LOG_ERROR, "Not enough memory to alocate call token\n");
|
||||
ast_rtp_destroy(pvt->rtp);
|
||||
free(pvt);
|
||||
ast_free(pvt);
|
||||
return NULL;
|
||||
}
|
||||
memset((char *)(pvt->cd).call_token, 0, 128);
|
||||
@@ -1210,7 +1209,7 @@ static struct oh323_alias *build_alias(const char *name, struct ast_variable *v,
|
||||
if (alias)
|
||||
found++;
|
||||
else {
|
||||
if (!(alias = (struct oh323_alias *)calloc(1, sizeof(*alias))))
|
||||
if (!(alias = ast_calloc(1, sizeof(*alias))))
|
||||
return NULL;
|
||||
ASTOBJ_INIT(alias);
|
||||
}
|
||||
@@ -1379,7 +1378,7 @@ static struct oh323_user *build_user(char *name, struct ast_variable *v, struct
|
||||
if (user)
|
||||
found++;
|
||||
else {
|
||||
if (!(user = (struct oh323_user *)calloc(1, sizeof(*user))))
|
||||
if (!(user = ast_calloc(1, sizeof(*user))))
|
||||
return NULL;
|
||||
ASTOBJ_INIT(user);
|
||||
}
|
||||
@@ -1496,7 +1495,7 @@ static struct oh323_peer *build_peer(const char *name, struct ast_variable *v, s
|
||||
if (peer)
|
||||
found++;
|
||||
else {
|
||||
if (!(peer = (struct oh323_peer*)calloc(1, sizeof(*peer))))
|
||||
if (!(peer = ast_calloc(1, sizeof(*peer))))
|
||||
return NULL;
|
||||
ASTOBJ_INIT(peer);
|
||||
}
|
||||
@@ -1908,14 +1907,14 @@ static struct rtp_info *external_rtp_create(unsigned call_reference, const char
|
||||
struct sockaddr_in us;
|
||||
struct rtp_info *info;
|
||||
|
||||
info = (struct rtp_info *)malloc(sizeof(struct rtp_info));
|
||||
info = ast_calloc(1, sizeof(*info));
|
||||
if (!info) {
|
||||
ast_log(LOG_ERROR, "Unable to allocated info structure, this is very bad\n");
|
||||
return NULL;
|
||||
}
|
||||
pvt = find_call_locked(call_reference, token);
|
||||
if (!pvt) {
|
||||
free(info);
|
||||
ast_free(info);
|
||||
ast_log(LOG_ERROR, "Unable to find call %s(%d)\n", token, call_reference);
|
||||
return NULL;
|
||||
}
|
||||
@@ -1923,7 +1922,7 @@ static struct rtp_info *external_rtp_create(unsigned call_reference, const char
|
||||
__oh323_rtp_create(pvt);
|
||||
if (!pvt->rtp) {
|
||||
ast_mutex_unlock(&pvt->lock);
|
||||
free(info);
|
||||
ast_free(info);
|
||||
ast_log(LOG_ERROR, "No RTP stream is available for call %s (%d)", token, call_reference);
|
||||
return NULL;
|
||||
}
|
||||
@@ -3337,7 +3336,7 @@ static int unload_module(void)
|
||||
p = p->next;
|
||||
/* free associated memory */
|
||||
ast_mutex_destroy(&pl->lock);
|
||||
free(pl);
|
||||
ast_free(pl);
|
||||
}
|
||||
iflist = NULL;
|
||||
ast_mutex_unlock(&iflock);
|
||||
|
@@ -238,7 +238,7 @@ static struct jingle_container jingles;
|
||||
|
||||
static void jingle_member_destroy(struct jingle *obj)
|
||||
{
|
||||
free(obj);
|
||||
ast_free(obj);
|
||||
}
|
||||
|
||||
static struct jingle *find_jingle(char *name, char *connection)
|
||||
@@ -691,9 +691,9 @@ static int jingle_create_candidates(struct jingle *client, struct jingle_pvt *p,
|
||||
|
||||
safeout:
|
||||
if (ours1)
|
||||
free(ours1);
|
||||
ast_free(ours1);
|
||||
if (ours2)
|
||||
free(ours2);
|
||||
ast_free(ours2);
|
||||
if (iq)
|
||||
iks_delete(iq);
|
||||
if (jingle)
|
||||
@@ -750,7 +750,7 @@ static struct jingle_pvt *jingle_alloc(struct jingle *client, const char *from,
|
||||
tmp->parent = client;
|
||||
if (!tmp->rtp) {
|
||||
ast_log(LOG_WARNING, "Out of RTP sessions?\n");
|
||||
free(tmp);
|
||||
ast_free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
ast_copy_string(tmp->exten, "s", sizeof(tmp->exten));
|
||||
@@ -883,7 +883,7 @@ static void jingle_free_candidates(struct jingle_candidate *candidate)
|
||||
while (candidate) {
|
||||
last = candidate;
|
||||
candidate = candidate->next;
|
||||
free(last);
|
||||
ast_free(last);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -911,7 +911,7 @@ static void jingle_free_pvt(struct jingle *client, struct jingle_pvt *p)
|
||||
if (p->vrtp)
|
||||
ast_rtp_destroy(p->vrtp);
|
||||
jingle_free_candidates(p->theircandidates);
|
||||
free(p);
|
||||
ast_free(p);
|
||||
}
|
||||
|
||||
|
||||
@@ -1465,8 +1465,7 @@ static struct jingle_candidate *jingle_create_candidate(char *args)
|
||||
{
|
||||
char *name, *type, *preference, *protocol;
|
||||
struct jingle_candidate *res;
|
||||
res = malloc(sizeof(struct jingle_candidate));
|
||||
memset(res, 0, sizeof(struct jingle_candidate));
|
||||
res = ast_calloc(1, sizeof(*res));
|
||||
if (args)
|
||||
name = args;
|
||||
if ((args = strchr(args, ','))) {
|
||||
@@ -1615,8 +1614,7 @@ static int jingle_load_config(void)
|
||||
while (cat) {
|
||||
if (strcasecmp(cat, "general")) {
|
||||
var = ast_variable_browse(cfg, cat);
|
||||
member = (struct jingle *) malloc(sizeof(struct jingle));
|
||||
memset(member, 0, sizeof(struct jingle));
|
||||
member = ast_calloc(1, sizeof(*member));
|
||||
ASTOBJ_INIT(member);
|
||||
ASTOBJ_WRLOCK(member);
|
||||
if (!strcasecmp(cat, "guest")) {
|
||||
|
@@ -584,7 +584,7 @@ static void dump_queue(struct mgcp_gateway *gw, struct mgcp_endpoint *p)
|
||||
while (q) {
|
||||
cur = q;
|
||||
q = q->next;
|
||||
free(cur);
|
||||
ast_free(cur);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -686,7 +686,7 @@ static int retrans_pkt(void *data)
|
||||
/* time-out transaction */
|
||||
handle_response(cur->owner_ep, cur->owner_sub, 406, cur->seqno, NULL);
|
||||
exq = exq->next;
|
||||
free(cur);
|
||||
ast_free(cur);
|
||||
}
|
||||
|
||||
return res;
|
||||
@@ -696,7 +696,7 @@ static int retrans_pkt(void *data)
|
||||
static int mgcp_postrequest(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
|
||||
char *data, int len, unsigned int seqno)
|
||||
{
|
||||
struct mgcp_message *msg = malloc(sizeof(struct mgcp_message) + len);
|
||||
struct mgcp_message *msg = ast_malloc(sizeof(*msg) + len);
|
||||
struct mgcp_message *cur;
|
||||
struct mgcp_gateway *gw = ((p && p->parent) ? p->parent : NULL);
|
||||
struct timeval tv;
|
||||
@@ -783,7 +783,7 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
|
||||
/* delete pending cx cmds */
|
||||
while (q) {
|
||||
r = q->next;
|
||||
free(q);
|
||||
ast_free(q);
|
||||
q = r;
|
||||
}
|
||||
*queue = NULL;
|
||||
@@ -810,13 +810,13 @@ static int send_request(struct mgcp_endpoint *p, struct mgcp_subchannel *sub,
|
||||
}
|
||||
}
|
||||
|
||||
r = (struct mgcp_request *) malloc (sizeof(struct mgcp_request));
|
||||
r = ast_malloc(sizeof(*r));
|
||||
if (!r) {
|
||||
ast_log(LOG_WARNING, "Cannot post MGCP request: insufficient memory\n");
|
||||
ast_mutex_unlock(l);
|
||||
return -1;
|
||||
}
|
||||
memcpy(r, req, sizeof(struct mgcp_request));
|
||||
memcpy(r, req, sizeof(*r));
|
||||
|
||||
if (!(*queue)) {
|
||||
if (mgcpdebug) {
|
||||
@@ -2026,10 +2026,9 @@ static int transmit_response(struct mgcp_subchannel *sub, char *msg, struct mgcp
|
||||
struct mgcp_response *mgr;
|
||||
|
||||
respprep(&resp, p, msg, req, msgrest);
|
||||
mgr = malloc(sizeof(struct mgcp_response) + resp.len + 1);
|
||||
mgr = ast_calloc(1, sizeof(*mgr) + resp.len + 1);
|
||||
if (mgr) {
|
||||
/* Store MGCP response in case we have to retransmit */
|
||||
memset(mgr, 0, sizeof(struct mgcp_response));
|
||||
sscanf(req->identifier, "%d", &mgr->seqno);
|
||||
time(&mgr->whensent);
|
||||
mgr->len = resp.len;
|
||||
@@ -2384,27 +2383,27 @@ static void dump_cmd_queues(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
|
||||
|
||||
if (p) {
|
||||
ast_mutex_lock(&p->rqnt_queue_lock);
|
||||
for (q = p->rqnt_queue; q; t = q->next, free(q), q=t);
|
||||
for (q = p->rqnt_queue; q; t = q->next, ast_free(q), q=t);
|
||||
p->rqnt_queue = NULL;
|
||||
ast_mutex_unlock(&p->rqnt_queue_lock);
|
||||
|
||||
ast_mutex_lock(&p->cmd_queue_lock);
|
||||
for (q = p->cmd_queue; q; t = q->next, free(q), q=t);
|
||||
for (q = p->cmd_queue; q; t = q->next, ast_free(q), q=t);
|
||||
p->cmd_queue = NULL;
|
||||
ast_mutex_unlock(&p->cmd_queue_lock);
|
||||
|
||||
ast_mutex_lock(&p->sub->cx_queue_lock);
|
||||
for (q = p->sub->cx_queue; q; t = q->next, free(q), q=t);
|
||||
for (q = p->sub->cx_queue; q; t = q->next, ast_free(q), q=t);
|
||||
p->sub->cx_queue = NULL;
|
||||
ast_mutex_unlock(&p->sub->cx_queue_lock);
|
||||
|
||||
ast_mutex_lock(&p->sub->next->cx_queue_lock);
|
||||
for (q = p->sub->next->cx_queue; q; t = q->next, free(q), q=t);
|
||||
for (q = p->sub->next->cx_queue; q; t = q->next, ast_free(q), q=t);
|
||||
p->sub->next->cx_queue = NULL;
|
||||
ast_mutex_unlock(&p->sub->next->cx_queue_lock);
|
||||
} else if (sub) {
|
||||
ast_mutex_lock(&sub->cx_queue_lock);
|
||||
for (q = sub->cx_queue; q; t = q->next, free(q), q=t);
|
||||
for (q = sub->cx_queue; q; t = q->next, ast_free(q), q=t);
|
||||
sub->cx_queue = NULL;
|
||||
ast_mutex_unlock(&sub->cx_queue_lock);
|
||||
}
|
||||
@@ -2607,7 +2606,7 @@ static void handle_response(struct mgcp_endpoint *p, struct mgcp_subchannel *sub
|
||||
}
|
||||
}
|
||||
|
||||
free(req);
|
||||
ast_free(req);
|
||||
}
|
||||
|
||||
static void start_rtp(struct mgcp_subchannel *sub)
|
||||
@@ -3313,7 +3312,7 @@ static int find_and_retrans(struct mgcp_subchannel *sub, struct mgcp_request *re
|
||||
prev->next = next;
|
||||
else
|
||||
sub->parent->parent->responses = next;
|
||||
free(cur);
|
||||
ast_free(cur);
|
||||
} else {
|
||||
if (seqno == cur->seqno)
|
||||
answer = cur;
|
||||
@@ -3390,7 +3389,7 @@ static int mgcpsock_read(int *id, int fd, short events, void *ignore)
|
||||
ast_mutex_unlock(&gw->msgs_lock);
|
||||
if (cur) {
|
||||
handle_response(cur->owner_ep, cur->owner_sub, result, ident, &req);
|
||||
free(cur);
|
||||
ast_free(cur);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -3614,11 +3613,10 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
}
|
||||
|
||||
if (!gw)
|
||||
gw = malloc(sizeof(struct mgcp_gateway));
|
||||
gw = ast_calloc(1, sizeof(*gw));
|
||||
|
||||
if (gw) {
|
||||
if (!gw_reload) {
|
||||
memset(gw, 0, sizeof(struct mgcp_gateway));
|
||||
gw->expire = -1;
|
||||
gw->retransid = -1; /* SC */
|
||||
ast_mutex_init(&gw->msgs_lock);
|
||||
@@ -3647,7 +3645,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
if (ast_get_ip(&gw->addr, v->value)) {
|
||||
if (!gw_reload) {
|
||||
ast_mutex_destroy(&gw->msgs_lock);
|
||||
free(gw);
|
||||
ast_free(gw);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -3656,7 +3654,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
if (ast_get_ip(&gw->defaddr, v->value)) {
|
||||
if (!gw_reload) {
|
||||
ast_mutex_destroy(&gw->msgs_lock);
|
||||
free(gw);
|
||||
ast_free(gw);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -3741,7 +3739,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
|
||||
if (!e) {
|
||||
/* Allocate wildcard endpoint */
|
||||
e = malloc(sizeof(struct mgcp_endpoint));
|
||||
e = ast_calloc(1, sizeof(*e));
|
||||
ep_reload = 0;
|
||||
}
|
||||
|
||||
@@ -3797,10 +3795,9 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
if (!ep_reload) {
|
||||
/*snprintf(txident, sizeof(txident), "%08lx", ast_random());*/
|
||||
for (i = 0; i < MAX_SUBS; i++) {
|
||||
sub = malloc(sizeof(struct mgcp_subchannel));
|
||||
sub = ast_calloc(1, sizeof(*sub));
|
||||
if (sub) {
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Allocating subchannel '%d' on %s@%s\n", i, e->name, gw->name);
|
||||
memset(sub, 0, sizeof(struct mgcp_subchannel));
|
||||
ast_mutex_init(&sub->lock);
|
||||
ast_mutex_init(&sub->cx_queue_lock);
|
||||
sub->parent = e;
|
||||
@@ -3846,13 +3843,12 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
}
|
||||
|
||||
if (!e) {
|
||||
e = malloc(sizeof(struct mgcp_endpoint));
|
||||
e = ast_calloc(1, sizeof(*e));
|
||||
ep_reload = 0;
|
||||
}
|
||||
|
||||
if (e) {
|
||||
if (!ep_reload) {
|
||||
memset(e, 0, sizeof(struct mgcp_endpoint));
|
||||
ast_mutex_init(&e->lock);
|
||||
ast_mutex_init(&e->rqnt_queue_lock);
|
||||
ast_mutex_init(&e->cmd_queue_lock);
|
||||
@@ -3905,7 +3901,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
|
||||
for (i = 0, sub = NULL; i < MAX_SUBS; i++) {
|
||||
if (!ep_reload) {
|
||||
sub = malloc(sizeof(struct mgcp_subchannel));
|
||||
sub = ast_calloc(1, sizeof(*sub));
|
||||
} else {
|
||||
if (!sub)
|
||||
sub = e->sub;
|
||||
@@ -3916,7 +3912,6 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
if (sub) {
|
||||
if (!ep_reload) {
|
||||
ast_verbose(VERBOSE_PREFIX_3 "Allocating subchannel '%d' on %s@%s\n", i, e->name, gw->name);
|
||||
memset(sub, 0, sizeof(struct mgcp_subchannel));
|
||||
ast_mutex_init(&sub->lock);
|
||||
ast_mutex_init(&sub->cx_queue_lock);
|
||||
ast_copy_string(sub->magic, MGCP_SUBCHANNEL_MAGIC, sizeof(sub->magic));
|
||||
@@ -3957,7 +3952,7 @@ static struct mgcp_gateway *build_gateway(char *cat, struct ast_variable *v)
|
||||
ast_log(LOG_WARNING, "Gateway '%s' lacks IP address and isn't dynamic\n", gw->name);
|
||||
if (!gw_reload) {
|
||||
ast_mutex_destroy(&gw->msgs_lock);
|
||||
free(gw);
|
||||
ast_free(gw);
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -4041,7 +4036,7 @@ static void destroy_endpoint(struct mgcp_endpoint *e)
|
||||
sub = sub->next;
|
||||
ast_mutex_destroy(&s->lock);
|
||||
ast_mutex_destroy(&s->cx_queue_lock);
|
||||
free(s);
|
||||
ast_free(s);
|
||||
}
|
||||
|
||||
if (e->mwi_event_sub)
|
||||
@@ -4050,7 +4045,7 @@ static void destroy_endpoint(struct mgcp_endpoint *e)
|
||||
ast_mutex_destroy(&e->lock);
|
||||
ast_mutex_destroy(&e->rqnt_queue_lock);
|
||||
ast_mutex_destroy(&e->cmd_queue_lock);
|
||||
free(e);
|
||||
ast_free(e);
|
||||
}
|
||||
|
||||
static void destroy_gateway(struct mgcp_gateway *g)
|
||||
@@ -4060,7 +4055,7 @@ static void destroy_gateway(struct mgcp_gateway *g)
|
||||
|
||||
dump_queue(g, NULL);
|
||||
|
||||
free (g);
|
||||
ast_free(g);
|
||||
}
|
||||
|
||||
static void prune_gateways(void)
|
||||
|
@@ -122,7 +122,7 @@ static void nbs_destroy(struct nbs_pvt *p)
|
||||
if (p->nbs)
|
||||
nbs_delstream(p->nbs);
|
||||
ast_module_user_remove(p->u);
|
||||
free(p);
|
||||
ast_free(p);
|
||||
}
|
||||
|
||||
static struct nbs_pvt *nbs_alloc(void *data)
|
||||
@@ -138,9 +138,8 @@ static struct nbs_pvt *nbs_alloc(void *data)
|
||||
opts++;
|
||||
} else
|
||||
opts = "";
|
||||
p = malloc(sizeof(struct nbs_pvt));
|
||||
p = ast_calloc(1, sizeof(*p));
|
||||
if (p) {
|
||||
memset(p, 0, sizeof(struct nbs_pvt));
|
||||
if (!ast_strlen_zero(opts)) {
|
||||
if (strchr(opts, 'm'))
|
||||
flags |= NBS_FLAG_MUTE;
|
||||
@@ -157,7 +156,7 @@ static struct nbs_pvt *nbs_alloc(void *data)
|
||||
p->nbs = nbs_newstream("asterisk", stream, flags);
|
||||
if (!p->nbs) {
|
||||
ast_log(LOG_WARNING, "Unable to allocate new NBS stream '%s' with flags %d\n", stream, flags);
|
||||
free(p);
|
||||
ast_free(p);
|
||||
p = NULL;
|
||||
} else {
|
||||
/* Set for 8000 hz mono, 640 samples */
|
||||
|
@@ -1179,12 +1179,12 @@ static struct phone_pvt *mkif(char *iface, int mode, int txgain, int rxgain)
|
||||
struct phone_pvt *tmp;
|
||||
int flags;
|
||||
|
||||
tmp = malloc(sizeof(struct phone_pvt));
|
||||
tmp = ast_calloc(1, sizeof(*tmp));
|
||||
if (tmp) {
|
||||
tmp->fd = open(iface, O_RDWR);
|
||||
if (tmp->fd < 0) {
|
||||
ast_log(LOG_WARNING, "Unable to open '%s'\n", iface);
|
||||
free(tmp);
|
||||
ast_free(tmp);
|
||||
return NULL;
|
||||
}
|
||||
if (mode == MODE_FXO) {
|
||||
@@ -1344,7 +1344,7 @@ static int __unload_module(void)
|
||||
pl = p;
|
||||
p = p->next;
|
||||
/* Free associated memory */
|
||||
free(pl);
|
||||
ast_free(pl);
|
||||
}
|
||||
iflist = NULL;
|
||||
ast_mutex_unlock(&iflock);
|
||||
|
Reference in New Issue
Block a user