diff options
author | Daniel Stenberg <daniel@haxx.se> | 2002-06-26 08:03:46 +0000 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2002-06-26 08:03:46 +0000 |
commit | a33e89b44a2b2d9c3a2a548604abb40d4d170734 (patch) | |
tree | cce884af30ab485c89dca114c989715023b93af7 /lib | |
parent | e203ecebeed73625604ffdb3e3e4d4ddb97bb76f (diff) |
Glen Nakamura's patch for Curl_getaddrinfo().
Diffstat (limited to 'lib')
-rw-r--r-- | lib/hostip.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/lib/hostip.c b/lib/hostip.c index 84ced78de..1707fd2d7 100644 --- a/lib/hostip.c +++ b/lib/hostip.c @@ -526,23 +526,27 @@ Curl_addrinfo *Curl_getaddrinfo(struct SessionHandle *data, if ( (in=inet_addr(hostname)) != INADDR_NONE ) { struct in_addr *addrentry; - long *buf = (long *)malloc(sizeof(struct hostent)+128); + struct namebuf { + struct hostent hostentry; + char *h_addr_list[2]; + struct in_addr addrentry; + char h_name[1]; + } *buf = (struct namebuf *)malloc(sizeof(struct namebuf)+128); if(!buf) return NULL; /* major failure */ *bufp = (char *)buf; - h = (struct hostent*)buf; - h->h_addr_list = (char**)(buf + sizeof(*h)); - addrentry = (struct in_addr*)(h->h_addr_list + 2); + h = &buf->hostentry; + h->h_addr_list = &buf->h_addr_list[0]; + addrentry = &buf->addrentry; addrentry->s_addr = in; h->h_addr_list[0] = (char*)addrentry; h->h_addr_list[1] = NULL; h->h_addrtype = AF_INET; h->h_length = sizeof(*addrentry); - h->h_name = *(h->h_addr_list) + h->h_length; - /* bad one h->h_name = (char*)(h->h_addr_list + h->h_length); */ - MakeIP(ntohl(in),h->h_name, sizeof(struct hostent)+128 - - (long)(h->h_name) + (long)buf); + h->h_name = &buf->h_name[0]; + MakeIP(ntohl(in), h->h_name, + sizeof(struct namebuf)+128 - (long)(h->h_name) + (long)buf); } #if defined(HAVE_GETHOSTBYNAME_R) else { |