[asterisk-commits] simon.perreault: branch group/v6-new r272650 - /team/group/v6-new/main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Jun 28 09:42:41 CDT 2010


Author: simon.perreault
Date: Mon Jun 28 09:42:37 2010
New Revision: 272650

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=272650
Log:
Use ast_str_thread_get() and other ast_str_* functions.

Modified:
    team/group/v6-new/main/netsock2.c

Modified: team/group/v6-new/main/netsock2.c
URL: http://svnview.digium.com/svn/asterisk/team/group/v6-new/main/netsock2.c?view=diff&rev=272650&r1=272649&r2=272650
==============================================================================
--- team/group/v6-new/main/netsock2.c (original)
+++ team/group/v6-new/main/netsock2.c Mon Jun 28 09:42:37 2010
@@ -66,7 +66,7 @@
 	const struct ast_sockaddr *sa_tmp;
 	char host[NI_MAXHOST];
 	char port[NI_MAXSERV];
-	char *str;
+	struct ast_str *str;
 	int e;
 	static const size_t size = sizeof(host) - 1 + sizeof(port) - 1 + 4;
 
@@ -75,7 +75,7 @@
 		return "(null)";
 	}
 
-	if (!(str = ast_threadstorage_get(&ast_sockaddr_stringify_buf, size))) {
+	if (!(str = ast_str_thread_get(&ast_sockaddr_stringify_buf, size))) {
 		return "";
 	}
 
@@ -97,25 +97,25 @@
 
 	switch (format)  {
 	case AST_SOCKADDR_STR_DEFAULT:
-		snprintf(str, size, sa_tmp->ss.ss_family == AF_INET6 ?
+		ast_str_set(&str, 0, sa_tmp->ss.ss_family == AF_INET6 ?
 				"[%s]:%s" : "%s:%s", host, port);
 		break;
 	case AST_SOCKADDR_STR_ADDR:
-		strncpy(str, host, size);
+		ast_copy_string(ast_str_buffer(str), host, ast_str_size(str));
 		break;
 	case AST_SOCKADDR_STR_HOST:
-		snprintf(str, size,
-			 sa_tmp->ss.ss_family == AF_INET6 ? "[%s]" : "%s", host);
+		ast_str_set(&str, 0,
+			    sa_tmp->ss.ss_family == AF_INET6 ? "[%s]" : "%s", host);
 		break;
 	case AST_SOCKADDR_STR_PORT:
-		strncpy(str, port, size);
+		ast_copy_string(ast_str_buffer(str), port, ast_str_size(str));
 		break;
 	default:
 		ast_log(LOG_ERROR, "Invalid format\n");
 		return "";
 	}
 
-	return str;
+	return ast_str_buffer(str);
 }
 
 int static _ast_sockaddr_parse(char *str, char **host, char **port, int flags)




More information about the asterisk-commits mailing list