Index: hostip.c
===================================================================
RCS file: /cvsroot/curl/curl/lib/hostip.c,v
retrieving revision 1.68
diff -c -3 -p -u -r1.68 hostip.c
--- hostip.c	11 Jun 2002 15:10:19 -0000	1.68
+++ hostip.c	25 Jun 2002 21:23:01 -0000
@@ -526,21 +526,25 @@ Curl_addrinfo *Curl_getaddrinfo(struct S
 
   if ( (in=inet_addr(hostname)) != INADDR_NONE ) {
     struct in_addr *addrentry;
-    long *buf = (long *)malloc(sizeof(struct hostent)+128);
+    struct buf {
+        struct hostent hostentry;
+        char *h_addr_list[2];
+        struct in_addr addrentry;
+        char h_name[1];
+    } *buf = (struct buf *)malloc(sizeof(struct hostent)+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); */
+    h->h_name = &buf->h_name[0];
     MakeIP(ntohl(in),h->h_name, sizeof(struct hostent)+128 -
            (long)(h->h_name) + (long)buf);
   }


