COMP: Remove alignment warning
This commit is contained in:
parent
766c093d69
commit
e0778d48bd
|
@ -403,15 +403,22 @@ Curl_addrinfo *Curl_he2ai(struct hostent *he, int port)
|
||||||
Curl_addrinfo *ai;
|
Curl_addrinfo *ai;
|
||||||
Curl_addrinfo *prevai = NULL;
|
Curl_addrinfo *prevai = NULL;
|
||||||
Curl_addrinfo *firstai = NULL;
|
Curl_addrinfo *firstai = NULL;
|
||||||
struct sockaddr_in *addr;
|
|
||||||
int i;
|
int i;
|
||||||
struct in_addr *curr;
|
|
||||||
|
union {
|
||||||
|
struct in_addr *addr;
|
||||||
|
char* list;
|
||||||
|
} curr;
|
||||||
|
union {
|
||||||
|
struct sockaddr_in* addr_in;
|
||||||
|
struct sockaddr* addr;
|
||||||
|
} address;
|
||||||
|
|
||||||
if(!he)
|
if(!he)
|
||||||
/* no input == no output! */
|
/* no input == no output! */
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
for(i=0; (curr = (struct in_addr *)he->h_addr_list[i]); i++) {
|
for(i=0; (curr.list = he->h_addr_list[i]); i++) {
|
||||||
|
|
||||||
ai = calloc(1, sizeof(Curl_addrinfo) + sizeof(struct sockaddr_in));
|
ai = calloc(1, sizeof(Curl_addrinfo) + sizeof(struct sockaddr_in));
|
||||||
|
|
||||||
|
@ -431,15 +438,15 @@ Curl_addrinfo *Curl_he2ai(struct hostent *he, int port)
|
||||||
ai->ai_addrlen = sizeof(struct sockaddr_in);
|
ai->ai_addrlen = sizeof(struct sockaddr_in);
|
||||||
/* make the ai_addr point to the address immediately following this struct
|
/* make the ai_addr point to the address immediately following this struct
|
||||||
and use that area to store the address */
|
and use that area to store the address */
|
||||||
ai->ai_addr = (struct sockaddr *) ((char*)ai + sizeof(Curl_addrinfo));
|
ai->ai_addr = (struct sockaddr *) (ai + 1);
|
||||||
|
|
||||||
/* leave the rest of the struct filled with zero */
|
/* leave the rest of the struct filled with zero */
|
||||||
|
|
||||||
addr = (struct sockaddr_in *)ai->ai_addr; /* storage area for this info */
|
address.addr = ai->ai_addr; /* storage area for this info */
|
||||||
|
|
||||||
memcpy((char *)&(addr->sin_addr), curr, sizeof(struct in_addr));
|
memcpy((char *)&(address.addr_in->sin_addr), curr.addr, sizeof(struct in_addr));
|
||||||
addr->sin_family = he->h_addrtype;
|
address.addr_in->sin_family = he->h_addrtype;
|
||||||
addr->sin_port = htons((unsigned short)port);
|
address.addr_in->sin_port = htons((unsigned short)port);
|
||||||
|
|
||||||
prevai = ai;
|
prevai = ai;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue