diff --git a/uv-common.c b/uv-common.c index c5d04ecf6a56..49d3b8b7ee79 100644 --- a/uv-common.c +++ b/uv-common.c @@ -23,6 +23,7 @@ #include #include /* NULL */ +#include /* memset */ static uv_counters_t counters; @@ -75,3 +76,16 @@ const char* uv_err_name(uv_err_t err) { return NULL; } } + + +struct sockaddr_in uv_ip4_addr(const char* ip, int port) { + struct sockaddr_in addr; + + memset(&addr, 0, sizeof(struct sockaddr_in)); + + addr.sin_family = AF_INET; + addr.sin_port = htons(port); + addr.sin_addr.s_addr = inet_addr(ip); + + return addr; +} diff --git a/uv-unix.c b/uv-unix.c index 7ec4de79bc93..df5775bcc8cf 100644 --- a/uv-unix.c +++ b/uv-unix.c @@ -122,19 +122,6 @@ static uv_err_t uv_err_new(uv_handle_t* handle, int sys_error) { } -struct sockaddr_in uv_ip4_addr(const char* ip, int port) { - struct sockaddr_in addr; - - memset(&addr, 0, sizeof(struct sockaddr_in)); - - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - addr.sin_addr.s_addr = inet_addr(ip); - - return addr; -} - - int uv_close(uv_handle_t* handle, uv_close_cb close_cb) { uv_tcp_t* tcp; uv_async_t* async; diff --git a/uv-win.c b/uv-win.c index 8d25a2a4ac83..7cfc371dac0f 100644 --- a/uv-win.c +++ b/uv-win.c @@ -705,17 +705,6 @@ int uv_close(uv_handle_t* handle, uv_close_cb close_cb) { } -struct sockaddr_in uv_ip4_addr(const char* ip, int port) { - struct sockaddr_in addr; - - addr.sin_family = AF_INET; - addr.sin_port = htons(port); - addr.sin_addr.s_addr = inet_addr(ip); - - return addr; -} - - int uv_bind(uv_tcp_t* handle, struct sockaddr_in addr) { DWORD err; int r;