提交 2e00c88c 编写于 作者: W wcc0

fix: add misc

fix porting

Change-Id: Iec5ed30d8f02095312ced41ac5ae869e8f9521a4
上级 109adc67
#define _GNU_SOURCE
#include <sys/socket.h>
#include <netdb.h>
#include <errno.h>
#include <stdlib.h>
struct hostent *gethostbyname2(const char *name, int af)
{
static struct hostent *h;
size_t size = 63;
struct hostent *res;
int err;
do {
free(h);
h = malloc(size+=size+1);
if (!h) {
h_errno = NO_RECOVERY;
return 0;
}
err = gethostbyname2_r(name, af, h,
(void *)(h+1), size-sizeof *h, &res, &h_errno);
} while (err == ERANGE);
return err ? 0 : h;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册