aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@redhat.com>2013-04-22 10:24:00 +0530
committerSiddhesh Poyarekar <siddhesh@redhat.com>2013-04-22 10:24:00 +0530
commit2169712d9c140d1b011470393c64258b2db3a4cd (patch)
tree55f1595389541c71d4922371acb173443847b58d
parent29c5de998411bba5ce8b70c7c82d95e8b68a740d (diff)
downloadglibc-2169712d9c140d1b011470393c64258b2db3a4cd.zip
glibc-2169712d9c140d1b011470393c64258b2db3a4cd.tar.gz
glibc-2169712d9c140d1b011470393c64258b2db3a4cd.tar.bz2
Minor cleanup in getaddrinfo
Replace repeated computations of alloca size with a local variable that stores the computed value.
-rw-r--r--ChangeLog5
-rw-r--r--sysdeps/posix/getaddrinfo.c7
2 files changed, 9 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0fff840..fffe816 100644
--- 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.
diff --git a/sysdeps/posix/getaddrinfo.c b/sysdeps/posix/getaddrinfo.c
index 2309281..d368306 100644
--- a/sysdeps/posix/getaddrinfo.c
+++ b/sysdeps/posix/getaddrinfo.c
@@ -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. */