arping: stop using last gethostbyname2 in the tree

hostname: small optimization
This commit is contained in:
Denis Vlasenko
2007-01-25 19:44:38 +00:00
parent aeb4bdd582
commit 90ec4dc0c7
3 changed files with 9 additions and 12 deletions

View File

@@ -305,13 +305,11 @@ int arping_main(int argc, char **argv)
}
if (!inet_aton(target, &dst)) {
struct hostent *hp;
hp = gethostbyname2(target, AF_INET);
if (!hp) {
bb_error_msg_and_die("invalid or unknown target %s", target);
}
memcpy(&dst, hp->h_addr, 4);
len_and_sockaddr *lsa;
lsa = host_and_af2sockaddr(target, 0, AF_INET);
memcpy(&dst, &lsa->sin.sin_addr.s_addr, 4);
if (ENABLE_FEATURE_CLEAN_UP)
free(lsa);
}
if (source && !inet_aton(source, &src)) {