[asterisk-commits] trunk - r8012 in /trunk/apps: app_milliwatt.c app_page.c app_rpt.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jan 12 10:08:07 CST 2006


Author: bweschke
Date: Thu Jan 12 10:08:06 2006
New Revision: 8012

URL: http://svn.digium.com/view/asterisk?rev=8012&view=rev
Log:
 More new memory wrapper work.


Modified:
    trunk/apps/app_milliwatt.c
    trunk/apps/app_page.c
    trunk/apps/app_rpt.c

Modified: trunk/apps/app_milliwatt.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_milliwatt.c?rev=8012&r1=8011&r2=8012&view=diff
==============================================================================
--- trunk/apps/app_milliwatt.c (original)
+++ trunk/apps/app_milliwatt.c Thu Jan 12 10:08:06 2006
@@ -60,7 +60,7 @@
 static void *milliwatt_alloc(struct ast_channel *chan, void *params)
 {
 int	*indexp;
-	indexp = malloc(sizeof(int));
+	indexp = ast_malloc(sizeof(*indexp));
 	if (indexp == NULL) return(NULL);
 	*indexp = 0;
 	return(indexp);

Modified: trunk/apps/app_page.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_page.c?rev=8012&r1=8011&r2=8012&view=diff
==============================================================================
--- trunk/apps/app_page.c (original)
+++ trunk/apps/app_page.c Thu Jan 12 10:08:06 2006
@@ -100,9 +100,8 @@
 	struct ast_var_t *varptr;
 	pthread_t t;
 	pthread_attr_t attr;
-	cd = malloc(sizeof(struct calloutdata));
+	cd = ast_calloc(1, sizeof(*cd));
 	if (cd) {
-		memset(cd, 0, sizeof(struct calloutdata));
 		ast_copy_string(cd->cidnum, chan->cid.cid_num ? chan->cid.cid_num : "", sizeof(cd->cidnum));
 		ast_copy_string(cd->cidname, chan->cid.cid_name ? chan->cid.cid_name : "", sizeof(cd->cidname));
 		ast_copy_string(cd->tech, tech, sizeof(cd->tech));

Modified: trunk/apps/app_rpt.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_rpt.c?rev=8012&r1=8011&r2=8012&view=diff
==============================================================================
--- trunk/apps/app_rpt.c (original)
+++ trunk/apps/app_rpt.c Thu Jan 12 10:08:06 2006
@@ -1313,7 +1313,7 @@
 				l = l->next;
 				continue;
 			}
-			m = malloc(sizeof(struct rpt_link));
+			m = ast_malloc(sizeof(*m));
 			if (!m)
 			{
 				ast_log(LOG_WARNING, "Cannot alloc memory on %s\n", mychannel->name);
@@ -1564,7 +1564,7 @@
 struct rpt_link *mylink = (struct rpt_link *) data;
 pthread_attr_t attr;
 
-	tele = malloc(sizeof(struct rpt_tele));
+	tele = ast_malloc(sizeof(*tele));
 	if (!tele)
 	{
 		ast_log(LOG_WARNING, "Unable to allocate memory\n");
@@ -1952,13 +1952,12 @@
 				ast_mutex_unlock(&myrpt->lock);
 			strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
 			/* establish call in monitor mode */
-			l = malloc(sizeof(struct rpt_link));
+			l = ast_calloc(1, sizeof(*l));
 			if (!l){
 				ast_log(LOG_WARNING, "Unable to malloc\n");
 				return DC_ERROR;
 			}
 			/* zero the silly thing */
-			memset((char *)l,0,sizeof(struct rpt_link));
 			snprintf(deststr, sizeof(deststr), "IAX2/%s", s1);
 			tele = strchr(deststr,'/');
 			if (!tele){
@@ -2066,13 +2065,11 @@
 				ast_mutex_unlock(&myrpt->lock);
 			strncpy(myrpt->lastlinknode,digitbuf,MAXNODESTR - 1);
 			/* establish call in tranceive mode */
-			l = malloc(sizeof(struct rpt_link));
+			l = ast_calloc(1, sizeof(*l));
 			if (!l){
 				ast_log(LOG_WARNING, "Unable to malloc\n");
 				return(DC_ERROR);
 			}
-			/* zero the silly thing */
-			memset((char *)l,0,sizeof(struct rpt_link));
 			l->mode = 1;
 			l->outbound = 1;
 			strncpy(l->name, digitbuf, MAXNODESTR - 1);
@@ -6017,7 +6014,7 @@
 		}
 
 		l=strlen(options)+2;
-		orig_s=malloc(l);
+		orig_s=ast_malloc(l);
 		if(!orig_s) {
 			ast_log(LOG_WARNING, "Out of memory\n");
 			return -1;
@@ -6229,14 +6226,12 @@
 		} else 
 			ast_mutex_unlock(&myrpt->lock);
 		/* establish call in tranceive mode */
-		l = malloc(sizeof(struct rpt_link));
+		l = ast_calloc(1, sizeof(*l));
 		if (!l)
 		{
 			ast_log(LOG_WARNING, "Unable to malloc\n");
 			pthread_exit(NULL);
 		}
-		/* zero the silly thing */
-		memset((char *)l,0,sizeof(struct rpt_link));
 		l->mode = 1;
 		strncpy(l->name,b1,MAXNODESTR - 1);
 		l->isremote = 0;



More information about the asterisk-commits mailing list