From 4f047eb1873141d932b77c96895f4f4e49aa5e97 Mon Sep 17 00:00:00 2001 From: Lassi Kortela Date: Fri, 9 Aug 2019 21:57:26 +0300 Subject: [PATCH] Replace BSD bzero() with standard memset() --- c/socket.c | 10 +++------- c/socket.h | 3 --- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/c/socket.c b/c/socket.c index 3afc063..fb251ab 100644 --- a/c/socket.c +++ b/c/socket.c @@ -38,10 +38,6 @@ void set_nonblock(int socket, int yes) fcntl(socket, F_SETFL, flags & ~O_NONBLOCK); } -#ifdef WIN32 -void bzero(void *s, size_t n) { memset(s, 0, n); } -#endif - /* returns a socket on which to accept() connections */ int open_tcp_port(short portno) { @@ -51,7 +47,7 @@ int open_tcp_port(short portno) sockfd = mysocket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sockfd < 0) return -1; - bzero(&serv_addr, sizeof(serv_addr)); + memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(portno); @@ -74,7 +70,7 @@ int open_any_tcp_port(short *portno) sockfd = mysocket(PF_INET, SOCK_STREAM, IPPROTO_TCP); if (sockfd < 0) return -1; - bzero(&serv_addr, sizeof(serv_addr)); + memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(*portno); @@ -98,7 +94,7 @@ int open_any_udp_port(short *portno) sockfd = mysocket(PF_INET, SOCK_DGRAM, 0); if (sockfd < 0) return -1; - bzero(&serv_addr, sizeof(serv_addr)); + memset(&serv_addr, 0, sizeof(serv_addr)); serv_addr.sin_family = AF_INET; serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_port = htons(*portno); diff --git a/c/socket.h b/c/socket.h index 2f3d663..3604fe4 100644 --- a/c/socket.h +++ b/c/socket.h @@ -18,9 +18,6 @@ int readall(int sockfd, char *buffer, int bufLen, int flags); int addr_eq(struct sockaddr_in *a, struct sockaddr_in *b); int socket_ready(int sock); -#ifdef WIN32 -void bzero(void *s, size_t n); -#endif #ifndef WIN32 void closesocket(int fd); #endif