diff options
author | bweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-13 03:25:23 +0000 |
---|---|---|
committer | bweschke <bweschke@f38db490-d61c-443f-a65b-d21fe96a405b> | 2006-01-13 03:25:23 +0000 |
commit | bb26a9138e13c01ab7fba613854fabb788341d45 (patch) | |
tree | ac5d62b21dfc242f96e660a8c9bb029b300701cb /apps/app_queue.c | |
parent | bb937ba384db12002f07934de383c3bf47a4cbe8 (diff) |
More memory wrapper and cleanup work. #6226 w/one very minor compile fix mod in app_rpt.c
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@8044 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_queue.c')
-rw-r--r-- | apps/app_queue.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c index 7afb2a83d..ab4b2af97 100644 --- a/apps/app_queue.c +++ b/apps/app_queue.c @@ -514,9 +514,8 @@ static int statechange_queue(const char *dev, int state, void *ign) struct statechange *sc; pthread_t t; pthread_attr_t attr; - - sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1); - if (sc) { + + if ((sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1))) { sc->state = state; strcpy(sc->dev, dev); pthread_attr_init(&attr); @@ -535,9 +534,7 @@ static struct member *create_queue_member(char *interface, int penalty, int paus /* Add a new member */ - cur = ast_calloc(1, sizeof(*cur)); - - if (cur) { + if ((cur = ast_calloc(1, sizeof(*cur)))) { cur->penalty = penalty; cur->paused = paused; ast_copy_string(cur->interface, interface, sizeof(cur->interface)); @@ -553,8 +550,7 @@ static struct ast_call_queue *alloc_queue(const char *queuename) { struct ast_call_queue *q; - q = ast_calloc(1, sizeof(*q)); - if (q) { + if ((q = ast_calloc(1, sizeof(*q)))) { ast_mutex_init(&q->lock); ast_copy_string(q->name, queuename, sizeof(q->name)); } @@ -827,8 +823,7 @@ static struct ast_call_queue *find_queue_by_name_rt(const char *queuename, struc /* Create a new queue if an in-core entry does not exist yet. */ if (!q) { - q = alloc_queue(queuename); - if (!q) + if (!(q = alloc_queue(queuename))) return NULL; ast_mutex_lock(&q->lock); clear_queue(q); @@ -1704,11 +1699,8 @@ static struct localuser *wait_for_answer(struct queue_ent *qe, struct localuser if (in->cid.cid_ani) { if (o->chan->cid.cid_ani) free(o->chan->cid.cid_ani); - 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 = ast_calloc(1, strlen(in->cid.cid_ani) + 1))) strncpy(o->chan->cid.cid_ani, in->cid.cid_ani, strlen(in->cid.cid_ani) + 1); - else - ast_log(LOG_WARNING, "Out of memory\n"); } if (o->chan->cid.cid_rdnis) free(o->chan->cid.cid_rdnis); @@ -2060,12 +2052,10 @@ static int try_calling(struct queue_ent *qe, const char *options, char *announce announce = announceoverride; while(cur) { - tmp = ast_calloc(1, sizeof(*tmp)); - if (!tmp) { + if (!(tmp = ast_calloc(1, sizeof(*tmp)))) { ast_mutex_unlock(&qe->parent->lock); if (use_weight) ast_mutex_unlock(&qlock); - ast_log(LOG_WARNING, "Out of memory\n"); goto out; } tmp->stillgoing = -1; @@ -3204,7 +3194,9 @@ static void reload_queues(void) } if (!q) { /* Make one then */ - q = alloc_queue(cat); + if (!(q = alloc_queue(cat))) { + /* TODO: Handle memory allocation failure */ + } new = 1; } else new = 0; @@ -3681,8 +3673,8 @@ static char *complete_add_queue_member(char *line, char *word, int pos, int stat } case 7: if (state < 100) { /* 0-99 */ - char *num = ast_malloc(3); - if (num) { + char *num; + if ((num = ast_malloc(3))) { sprintf(num, "%d", state); } return num; |