aboutsummaryrefslogtreecommitdiff
path: root/nis/nis_call.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2005-12-09 06:48:51 +0000
committerUlrich Drepper <drepper@redhat.com>2005-12-09 06:48:51 +0000
commit929b1c07081afacabd347728609b1522f9ddb0a4 (patch)
treec0a3bd34a2e8f92e68c09fcf881b2285b878a746 /nis/nis_call.c
parent8c058eec1e5ea88c64056fe2edef6a11b174756c (diff)
downloadglibc-929b1c07081afacabd347728609b1522f9ddb0a4.zip
glibc-929b1c07081afacabd347728609b1522f9ddb0a4.tar.gz
glibc-929b1c07081afacabd347728609b1522f9ddb0a4.tar.bz2
* nis/nis_call.c (inetstr2int): Optimize.
Diffstat (limited to 'nis/nis_call.c')
-rw-r--r--nis/nis_call.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/nis/nis_call.c b/nis/nis_call.c
index 07f95f0..5b432b7 100644
--- a/nis/nis_call.c
+++ b/nis/nis_call.c
@@ -40,25 +40,16 @@ extern u_short __pmap_getnisport (struct sockaddr_in *address, u_long program,
unsigned long
inetstr2int (const char *str)
{
- char buffer[strlen (str) + 3];
- size_t buflen;
- size_t i, j;
-
- buflen = stpcpy (buffer, str) - buffer;
-
- j = 0;
- for (i = 0; i < buflen; ++i)
- if (buffer[i] == '.')
+ size_t j = 0;
+ for (size_t i = 0; str[i] != '\0'; ++i)
+ if (str[i] == '.' && ++j == 4)
{
- ++j;
- if (j == 4)
- {
- buffer[i] = '\0';
- break;
- }
+ char buffer[i + 1];
+ buffer[i] = '\0';
+ return inet_addr (memcpy (buffer, str, i));
}
- return inet_addr (buffer);
+ return inet_addr (str);
}
void