Use const pointers when possible

Sending data only require to read the input buffer, so declare it const.
This commit is contained in:
Romain Vimont 2018-04-04 10:42:13 +02:00
parent 6323f3974f
commit b2b5404883
2 changed files with 4 additions and 4 deletions

View file

@ -82,11 +82,11 @@ ssize_t net_recv_all(socket_t socket, void *buf, size_t len) {
return recv(socket, buf, len, MSG_WAITALL);
}
ssize_t net_send(socket_t socket, void *buf, size_t len) {
ssize_t net_send(socket_t socket, const void *buf, size_t len) {
return send(socket, buf, len, 0);
}
ssize_t net_send_all(socket_t socket, void *buf, size_t len) {
ssize_t net_send_all(socket_t socket, const void *buf, size_t len) {
ssize_t w;
while (len > 0) {
w = send(socket, buf, len, 0);

View file

@ -26,8 +26,8 @@ socket_t net_accept(socket_t server_socket);
// the _all versions wait/retry until len bytes have been written/read
ssize_t net_recv(socket_t socket, void *buf, size_t len);
ssize_t net_recv_all(socket_t socket, void *buf, size_t len);
ssize_t net_send(socket_t socket, void *buf, size_t len);
ssize_t net_send_all(socket_t socket, void *buf, size_t len);
ssize_t net_send(socket_t socket, const void *buf, size_t len);
ssize_t net_send_all(socket_t socket, const void *buf, size_t len);
// how is SHUT_RD (read), SHUT_WR (write) or SHUT_RDWR (both)
SDL_bool net_shutdown(socket_t socket, int how);
SDL_bool net_close(socket_t socket);