[asterisk-commits] trunk r36700 - /trunk/apps/app_meetme.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Jul 2 20:39:38 MST 2006


Author: russell
Date: Sun Jul  2 22:39:37 2006
New Revision: 36700

URL: http://svn.digium.com/view/asterisk?rev=36700&view=rev
Log:
- remove an unused variable
- use ast_calloc instead of malloc + memset
- return immediately on ast_calloc failure instead of indenting the whole func
- remove a duplicate ast_strdupa

Modified:
    trunk/apps/app_meetme.c

Modified: trunk/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_meetme.c?rev=36700&r1=36699&r2=36700&view=diff
==============================================================================
--- trunk/apps/app_meetme.c (original)
+++ trunk/apps/app_meetme.c Sun Jul  2 22:39:37 2006
@@ -2346,7 +2346,6 @@
 static void *sla_originate(void *data)
 {
 	struct sla_originate_helper *in = data;
-	int res;
 	int reason = 0;
 	struct ast_channel *chan = NULL;
 
@@ -2363,23 +2362,24 @@
 
 static void do_invite(struct ast_channel *orig, struct ast_sla *sla, const char *tech, const char *dest, const char *app)
 {
-	struct sla_originate_helper *slal = malloc(sizeof(struct sla_originate_helper));
+	struct sla_originate_helper *slal;
 	pthread_attr_t attr;
 	pthread_t th;
-	if (slal) {
-		memset(slal, 0, sizeof(struct sla_originate_helper));
-		ast_copy_string(slal->tech, tech, sizeof(slal->tech));
-   		ast_copy_string(slal->data, dest, sizeof(slal->data));
-		ast_copy_string(slal->app, app, sizeof(slal->app));
-		ast_copy_string(slal->appdata, sla->name, sizeof(slal->appdata));
-		if (orig->cid.cid_num)
-			ast_copy_string(slal->cid_num, orig->cid.cid_num, sizeof(slal->cid_num));
-		if (orig->cid.cid_name)
-			ast_copy_string(slal->cid_name, orig->cid.cid_name, sizeof(slal->cid_name));
-		pthread_attr_init(&attr);
-		pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
-		ast_pthread_create(&th, &attr, sla_originate, slal);
-	}
+
+	if (!(slal = ast_calloc(1, sizeof(*slal))))
+		return;
+	
+	ast_copy_string(slal->tech, tech, sizeof(slal->tech));
+   	ast_copy_string(slal->data, dest, sizeof(slal->data));
+	ast_copy_string(slal->app, app, sizeof(slal->app));
+	ast_copy_string(slal->appdata, sla->name, sizeof(slal->appdata));
+	if (orig->cid.cid_num)
+		ast_copy_string(slal->cid_num, orig->cid.cid_num, sizeof(slal->cid_num));
+	if (orig->cid.cid_name)
+		ast_copy_string(slal->cid_name, orig->cid.cid_name, sizeof(slal->cid_name));
+	pthread_attr_init(&attr);
+	pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+	ast_pthread_create(&th, &attr, sla_originate, slal);
 }
 
 static void invite_stations(struct ast_channel *orig, struct ast_sla *sla)
@@ -2431,9 +2431,6 @@
 	if (chan->_state != AST_STATE_UP)
 		ast_answer(chan);
 
-	info = ast_strdupa(data);
-
-	
 	if (args.options)
 		ast_app_parse_options(sla_opts, &confflags, NULL, args.options);
 		



More information about the asterisk-commits mailing list