const void *optval, socklen_t optlen)
{
/*
- * SO_REUSEADDR requests from tcp_listen.c
- * to permit another bind even when the
+ * SO_REUSEADDR requests to permit another bind even when the
* port is still in state TIME_WAIT. Windows' SO_REUSEADDR is
* broken: it makes bind() succeed no matter what, even if
* there's another server running on the same port. Luckily,
}
buffer = malloc(total_bytes);
- if (buffer == NULL)
+ if (buffer == NULL && total_bytes != 0)
return -1;
bytes_read = posix_read(fd, buffer, total_bytes);
for (i = 0; i < iovcnt; i++)
total_bytes += iov[i].iov_len;
- if (total_bytes == 0)
- return 0;
-
buffer = malloc(total_bytes);
- if (buffer == NULL)
+ if (buffer == NULL && total_bytes != 0)
return -1;
buffer_location = buffer;