[Asterisk-cvs] asterisk/channels chan_sip.c,1.717,1.718

kpfleming at lists.digium.com kpfleming at lists.digium.com
Mon May 2 09:37:24 CDT 2005


Update of /usr/cvsroot/asterisk/channels
In directory mongoose.digium.com:/tmp/cvs-serv1281/channels

Modified Files:
	chan_sip.c 
Log Message:
testing has shown that ast_copy_string is nearly twice as fast as strncpy for the common use cases in Asterisk, so convert chan_sip over...


Index: chan_sip.c
===================================================================
RCS file: /usr/cvsroot/asterisk/channels/chan_sip.c,v
retrieving revision 1.717
retrieving revision 1.718
diff -u -d -r1.717 -r1.718
--- chan_sip.c	2 May 2005 01:34:21 -0000	1.717
+++ chan_sip.c	2 May 2005 13:44:38 -0000	1.718
@@ -1025,7 +1025,7 @@
 			return -1;
 		}
 		cur = p->packets;
-		strncpy(method, p->packets->data, sizeof(method) - 1);
+		ast_copy_string(method, p->packets->data, sizeof(method));
 		c = method;
 		while(*c && (*c < 33)) c++;
 		*c = '\0';
@@ -1230,7 +1230,7 @@
 	unsigned char multi[256]="";
 	char *stringp, *ext;
[...1382 lines suppressed...]
 				ast_log(LOG_WARNING, "Invalid address for externhost keyword: %s\n", externhost);
 			else
@@ -10897,7 +10895,7 @@
 	/* we'll issue the redirect message here */
 	if (!host) {
 		char *localtmp;
-		strncpy(tmp, get_header(&p->initreq, "To"), sizeof(tmp) - 1);
+		ast_copy_string(tmp, get_header(&p->initreq, "To"), sizeof(tmp));
 		if (!strlen(tmp)) {
 			ast_log(LOG_ERROR, "Cannot retrieve the 'To' header from the original SIP request!\n");
 			return 0;
@@ -10929,7 +10927,7 @@
 	}
 
 	/* make sure the forwarding won't be forever */
-	strncpy(tmp, get_header(&p->initreq, "Max-Forwards"), sizeof(tmp) - 1);
+	ast_copy_string(tmp, get_header(&p->initreq, "Max-Forwards"), sizeof(tmp));
 	if (strlen(tmp) && atoi(tmp)) {
 		/* we found Max-Forwards in the original SIP request */
 		p->maxforwards = atoi(tmp) - 1;




More information about the svn-commits mailing list