[asterisk-commits] trunk - r8011 /trunk/apps/app_queue.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 12 10:00:14 CST 2006


Author: bweschke
Date: Thu Jan 12 10:00:13 2006
New Revision: 8011

URL: http://svn.digium.com/view/asterisk?rev=8011&view=rev
Log:
 More new memory wrapper work and initializing some memory allocations to zero where they weren't before.


Modified:
    trunk/apps/app_queue.c

Modified: trunk/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_queue.c?rev=8011&r1=8010&r2=8011&view=diff
==============================================================================
--- trunk/apps/app_queue.c (original)
+++ trunk/apps/app_queue.c Thu Jan 12 10:00:13 2006
@@ -515,7 +515,7 @@
 	pthread_t t;
 	pthread_attr_t attr;
 
-	sc = malloc(sizeof(struct statechange) + strlen(dev) + 1);
+	sc = ast_calloc(1, sizeof(*sc) + strlen(dev) + 1);
 	if (sc) {
 		sc->state = state;
 		strcpy(sc->dev, dev);
@@ -535,10 +535,9 @@
 	
 	/* Add a new member */
 
-	cur = malloc(sizeof(struct member));
+	cur = ast_calloc(1, sizeof(*cur));
 
 	if (cur) {
-		memset(cur, 0, sizeof(struct member));
 		cur->penalty = penalty;
 		cur->paused = paused;
 		ast_copy_string(cur->interface, interface, sizeof(cur->interface));
@@ -554,9 +553,8 @@
 {
 	struct ast_call_queue *q;
 
-	q = malloc(sizeof(*q));
+	q = ast_calloc(1, sizeof(*q));
 	if (q) {
-		memset(q, 0, sizeof(*q));
 		ast_mutex_init(&q->lock);
 		ast_copy_string(q->name, queuename, sizeof(q->name));
 	}
@@ -1707,7 +1705,7 @@
 						if (in->cid.cid_ani) {
 							if (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)
 								strncpy(o->chan->cid.cid_ani, in->cid.cid_ani, strlen(in->cid.cid_ani) + 1);
 							else
@@ -2063,7 +2061,7 @@
 		announce = announceoverride;
 
 	while(cur) {
-		tmp = malloc(sizeof(*tmp));
+		tmp = ast_calloc(1, sizeof(*tmp));
 		if (!tmp) {
 			ast_mutex_unlock(&qe->parent->lock);
 			if (use_weight) 
@@ -2071,7 +2069,6 @@
 			ast_log(LOG_WARNING, "Out of memory\n");
 			goto out;
 		}
-		memset(tmp, 0, sizeof(*tmp));
 		tmp->stillgoing = -1;
 		if (option_debug) {
 			if (url)
@@ -3685,7 +3682,7 @@
 		}
 	case 7:
 		if (state < 100) {	/* 0-99 */
-			char *num = malloc(3);
+			char *num = ast_malloc(3);
 			if (num) {
 				sprintf(num, "%d", state);
 			}



More information about the asterisk-commits mailing list