]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Minor cleanup in getaddrinfo
authorSiddhesh Poyarekar <siddhesh@redhat.com>
Mon, 22 Apr 2013 04:54:00 +0000 (10:24 +0530)
committerSiddhesh Poyarekar <siddhesh@redhat.com>
Mon, 22 Apr 2013 04:54:00 +0000 (10:24 +0530)
Replace repeated computations of alloca size with a local variable
that stores the computed value.

ChangeLog
sysdeps/posix/getaddrinfo.c

index 0fff840f7203dc7e006d8f6b7312dd15ce10f2a0..fffe816c046eda704c767a5b437325daaf866936 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2013-04-22  Siddhesh Poyarekar  <siddhesh@redhat.com>
+
+       * sysdeps/posix/getaddrinfo.c (getaddrinfo): Compute results
+       size just once.
+
 2013-04-21  David S. Miller  <davem@davemloft.net>
 
        * po/ru.po: Update Russion translation from translation project.
index 230928181cbf84172a1e1a15a3e9c5cb28c9ccbf..d3683066ae2e1ea0d37d53a24979f567467ddff6 100644 (file)
@@ -2495,12 +2495,13 @@ getaddrinfo (const char *name, const char *service,
       struct addrinfo *last = NULL;
       char *canonname = NULL;
       bool malloc_results;
+      size_t alloc_size = nresults * (sizeof (*results) + sizeof (size_t));
 
       malloc_results
-       = !__libc_use_alloca (nresults * (sizeof (*results) + sizeof (size_t)));
+       = !__libc_use_alloca (alloc_size);
       if (malloc_results)
        {
-         results = malloc (nresults * (sizeof (*results) + sizeof (size_t)));
+         results = malloc (alloc_size);
          if (results == NULL)
            {
              __free_in6ai (in6ai);
@@ -2508,7 +2509,7 @@ getaddrinfo (const char *name, const char *service,
            }
        }
       else
-       results = alloca (nresults * (sizeof (*results) + sizeof (size_t)));
+       results = alloca (alloc_size);
       order = (size_t *) (results + nresults);
 
       /* Now we definitely need the interface information.  */