about summary refs log tree commit diff
path: root/sysdeps/posix/getaddrinfo.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2004-08-19 22:56:27 +0000
committerUlrich Drepper <drepper@redhat.com>2004-08-19 22:56:27 +0000
commita24c5ac46258a0fff7a00c501440ba49381a2338 (patch)
treecbbb607ea261352372b3c114e820b21a5c39cac5 /sysdeps/posix/getaddrinfo.c
parentafd7b703335c65d616b6198c1aa407cfbba5edea (diff)
downloadglibc-a24c5ac46258a0fff7a00c501440ba49381a2338.tar.gz
glibc-a24c5ac46258a0fff7a00c501440ba49381a2338.tar.xz
glibc-a24c5ac46258a0fff7a00c501440ba49381a2338.zip
Update.
	* sysdeps/posix/getaddrinfo.c (gaih_inet): Minor optimizations in
	list generation.
Diffstat (limited to 'sysdeps/posix/getaddrinfo.c')
-rw-r--r--sysdeps/posix/getaddrinfo.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 132fdcc620..3ffa329f73 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -848,30 +848,31 @@ gaih_inet (const char *name, const struct gaih_service *service,
 
 	for (st2 = st; st2 != NULL; st2 = st2->next)
 	  {
-	    *pai = malloc (sizeof (struct addrinfo) + socklen);
-	    if (*pai == NULL)
+	    struct addrinfo *ai;
+	    ai = *pai = malloc (sizeof (struct addrinfo) + socklen);
+	    if (ai == NULL)
 	      return -EAI_MEMORY;
 
-	    (*pai)->ai_flags = req->ai_flags;
-	    (*pai)->ai_family = family;
-	    (*pai)->ai_socktype = st2->socktype;
-	    (*pai)->ai_protocol = st2->protocol;
-	    (*pai)->ai_addrlen = socklen;
-	    (*pai)->ai_addr = (void *) (*pai + 1);
+	    ai->ai_flags = req->ai_flags;
+	    ai->ai_family = family;
+	    ai->ai_socktype = st2->socktype;
+	    ai->ai_protocol = st2->protocol;
+	    ai->ai_addrlen = socklen;
+	    ai->ai_addr = (void *) (ai + 1);
 
 	    /* We only add the canonical name once.  */
-	    (*pai)->ai_canonname = (char *) canon;
+	    ai->ai_canonname = (char *) canon;
 	    canon = NULL;
 
 #if SALEN
-	    (*pai)->ai_addr->sa_len = socklen;
+	    ai->ai_addr->sa_len = socklen;
 #endif /* SALEN */
-	    (*pai)->ai_addr->sa_family = family;
+	    ai->ai_addr->sa_family = family;
 
 	    if (family == AF_INET6)
 	      {
 		struct sockaddr_in6 *sin6p =
-		  (struct sockaddr_in6 *) (*pai)->ai_addr;
+		  (struct sockaddr_in6 *) ai->ai_addr;
 
 		sin6p->sin6_port = st2->port;
 		sin6p->sin6_flowinfo = 0;
@@ -882,16 +883,16 @@ gaih_inet (const char *name, const struct gaih_service *service,
 	    else
 	      {
 		struct sockaddr_in *sinp =
-		  (struct sockaddr_in *) (*pai)->ai_addr;
+		  (struct sockaddr_in *) ai->ai_addr;
 		sinp->sin_port = st2->port;
 		memcpy (&sinp->sin_addr,
 			at2->addr, sizeof (struct in_addr));
 		memset (sinp->sin_zero, '\0', sizeof (sinp->sin_zero));
 	      }
 
-	    (*pai)->ai_next = NULL;
-	    pai = &((*pai)->ai_next);
+	    pai = &(ai->ai_next);
 	  }
+	*pai = NULL;
 
       ignore:
 	at2 = at2->next;