More new memory wrapper work and initializing some memory allocations to zero where they weren't before.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8011 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
BJ Weschke
2006-01-12 16:00:13 +00:00
parent 57fe2e8ea2
commit e825a748cf

View File

@@ -515,7 +515,7 @@ static int statechange_queue(const char *dev, int state, void *ign)
pthread_t t; pthread_t t;
pthread_attr_t attr; pthread_attr_t attr;
sc = malloc(sizeof(struct statechange) + strlen(dev) + 1); sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1);
if (sc) { if (sc) {
sc->state = state; sc->state = state;
strcpy(sc->dev, dev); strcpy(sc->dev, dev);
@@ -535,10 +535,9 @@ static struct member *create_queue_member(char *interface, int penalty, int paus
/* Add a new member */ /* Add a new member */
cur = malloc(sizeof(struct member)); cur = ast_calloc(1, sizeof(*cur));
if (cur) { if (cur) {
memset(cur, 0, sizeof(struct member));
cur->penalty = penalty; cur->penalty = penalty;
cur->paused = paused; cur->paused = paused;
ast_copy_string(cur->interface, interface, sizeof(cur->interface)); ast_copy_string(cur->interface, interface, sizeof(cur->interface));
@@ -554,9 +553,8 @@ static struct ast_call_queue *alloc_queue(const char *queuename)
{ {
struct ast_call_queue *q; struct ast_call_queue *q;
q = malloc(sizeof(*q)); q = ast_calloc(1, sizeof(*q));
if (q) { if (q) {
memset(q, 0, sizeof(*q));
ast_mutex_init(&q->lock); ast_mutex_init(&q->lock);
ast_copy_string(q->name, queuename, sizeof(q->name)); ast_copy_string(q->name, queuename, sizeof(q->name));
} }
@@ -1707,7 +1705,7 @@ static struct localuser *wait_for_answer(struct queue_ent *qe, struct localuser
if (in->cid.cid_ani) { if (in->cid.cid_ani) {
if (o->chan->cid.cid_ani) if (o->chan->cid.cid_ani)
free(o->chan->cid.cid_ani); free(o->chan->cid.cid_ani);
o->chan->cid.cid_ani = malloc(strlen(in->cid.cid_ani) + 1); o->chan->cid.cid_ani = ast_calloc(1, strlen(in->cid.cid_ani) + 1);
if (o->chan->cid.cid_ani) if (o->chan->cid.cid_ani)
strncpy(o->chan->cid.cid_ani, in->cid.cid_ani, strlen(in->cid.cid_ani) + 1); strncpy(o->chan->cid.cid_ani, in->cid.cid_ani, strlen(in->cid.cid_ani) + 1);
else else
@@ -2063,7 +2061,7 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
announce = announceoverride; announce = announceoverride;
while(cur) { while(cur) {
tmp = malloc(sizeof(*tmp)); tmp = ast_calloc(1, sizeof(*tmp));
if (!tmp) { if (!tmp) {
ast_mutex_unlock(&qe->parent->lock); ast_mutex_unlock(&qe->parent->lock);
if (use_weight) if (use_weight)
@@ -2071,7 +2069,6 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce
ast_log(LOG_WARNING, "Out of memory\n"); ast_log(LOG_WARNING, "Out of memory\n");
goto out; goto out;
} }
memset(tmp, 0, sizeof(*tmp));
tmp->stillgoing = -1; tmp->stillgoing = -1;
if (option_debug) { if (option_debug) {
if (url) if (url)
@@ -3685,7 +3682,7 @@ static char *complete_add_queue_member(char *line, char *word, int pos, int stat
} }
case 7: case 7:
if (state < 100) { /* 0-99 */ if (state < 100) { /* 0-99 */
char *num = malloc(3); char *num = ast_malloc(3);
if (num) { if (num) {
sprintf(num, "%d", state); sprintf(num, "%d", state);
} }