Replace BSD bzero() with standard memset()

This commit is contained in:
Lassi Kortela 2019-08-09 21:57:26 +03:00
parent 2b65fe4cef
commit 4f047eb187
2 changed files with 3 additions and 10 deletions

View File

@ -38,10 +38,6 @@ void set_nonblock(int socket, int yes)
fcntl(socket, F_SETFL, flags & ~O_NONBLOCK); 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 */ /* returns a socket on which to accept() connections */
int open_tcp_port(short portno) int open_tcp_port(short portno)
{ {
@ -51,7 +47,7 @@ int open_tcp_port(short portno)
sockfd = mysocket(PF_INET, SOCK_STREAM, IPPROTO_TCP); sockfd = mysocket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd < 0) if (sockfd < 0)
return -1; return -1;
bzero(&serv_addr, sizeof(serv_addr)); memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET; serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(portno); 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); sockfd = mysocket(PF_INET, SOCK_STREAM, IPPROTO_TCP);
if (sockfd < 0) if (sockfd < 0)
return -1; return -1;
bzero(&serv_addr, sizeof(serv_addr)); memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET; serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(*portno); serv_addr.sin_port = htons(*portno);
@ -98,7 +94,7 @@ int open_any_udp_port(short *portno)
sockfd = mysocket(PF_INET, SOCK_DGRAM, 0); sockfd = mysocket(PF_INET, SOCK_DGRAM, 0);
if (sockfd < 0) if (sockfd < 0)
return -1; return -1;
bzero(&serv_addr, sizeof(serv_addr)); memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET; serv_addr.sin_family = AF_INET;
serv_addr.sin_addr.s_addr = htonl(INADDR_ANY); serv_addr.sin_addr.s_addr = htonl(INADDR_ANY);
serv_addr.sin_port = htons(*portno); serv_addr.sin_port = htons(*portno);

View File

@ -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 addr_eq(struct sockaddr_in *a, struct sockaddr_in *b);
int socket_ready(int sock); int socket_ready(int sock);
#ifdef WIN32
void bzero(void *s, size_t n);
#endif
#ifndef WIN32 #ifndef WIN32
void closesocket(int fd); void closesocket(int fd);
#endif #endif