[Asterisk-cvs] asterisk rtp.c,1.121,1.122

kpfleming at lists.digium.com kpfleming at lists.digium.com
Tue Apr 5 22:51:17 CDT 2005


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

Modified Files:
	rtp.c 
Log Message:
use more efficient code to produce non-codec-capability list (bug #3960)


Index: rtp.c
===================================================================
RCS file: /usr/cvsroot/asterisk/rtp.c,v
retrieving revision 1.121
retrieving revision 1.122
diff -u -d -r1.121 -r1.122
--- rtp.c	5 Apr 2005 23:34:56 -0000	1.121
+++ rtp.c	6 Apr 2005 03:43:59 -0000	1.122
@@ -853,21 +853,35 @@
 char *ast_rtp_lookup_mime_multiple(char *buf, int size, const int capability, const int isAstFormat)
 {
 	int format;
+	unsigned len;
+	char *end = buf;
+	char *start = buf;
 
 	if (!buf || !size)
 		return NULL;
 
-	snprintf(buf, size, "0x%x (", capability);
+	snprintf(end, size, "0x%x (", capability);
+
+	len = strlen(end);
+	end += len;
+	size -= len;
+	start = end;
 
 	for (format = 1; format < AST_RTP_MAX; format <<= 1) {
 		if (capability & format) {
 			const char *name = ast_rtp_lookup_mime_subtype(isAstFormat, format);
-			snprintf(buf + strlen(buf), size - strlen(buf), "%s|", name);
+			snprintf(end, size, "%s|", name);
+			len = strlen(end);
+			end += len;
+			size -= len;
 		}
 	}
-	if (!ast_strlen_zero(buf))
-		buf[strlen(buf)] = ')';
 
+	if (start == end)
+		snprintf(start, size, "nothing)"); 
+	else if (size > 1)
+		*(end -1) = ')';
+	
 	return buf;
 }
 




More information about the svn-commits mailing list