From b666727b0d71fd22a91c540344a2ebb64d69d800 Mon Sep 17 00:00:00 2001
From: "Ryan C. Gordon" <[EMAIL REDACTED]>
Date: Wed, 23 Oct 2024 19:56:08 -0400
Subject: [PATCH] Convert several functions that return ints of 0 or -1 to
bools.
This matches SDL3 API policy.
Fixes #111.
---
cmake/test/main.c | 2 +-
examples/get-local-addrs.c | 2 +-
examples/resolve-hostnames.c | 2 +-
examples/simple-http-get.c | 4 +-
examples/voipchat.c | 4 +-
include/SDL3_net/SDL_net.h | 30 +++++++-------
src/SDL_net.c | 80 +++++++++++++++++++++---------------
7 files changed, 69 insertions(+), 55 deletions(-)
diff --git a/cmake/test/main.c b/cmake/test/main.c
index fcd462b..40ab4d3 100644
--- a/cmake/test/main.c
+++ b/cmake/test/main.c
@@ -9,7 +9,7 @@ int main(int argc, char *argv[])
return 1;
}
- if (SDLNet_Init() < 0) {
+ if (!SDLNet_Init()) {
SDL_Log("SDL_Net_Init() failed: %s", SDL_GetError());
}
diff --git a/examples/get-local-addrs.c b/examples/get-local-addrs.c
index 5dffc39..827a6c6 100644
--- a/examples/get-local-addrs.c
+++ b/examples/get-local-addrs.c
@@ -19,7 +19,7 @@ int main(int argc, char **argv)
(void)argc;
(void)argv;
- if (SDLNet_Init() < 0) {
+ if (!SDLNet_Init()) {
SDL_Log("SDLNet_Init() failed: %s", SDL_GetError());
return 1;
}
diff --git a/examples/resolve-hostnames.c b/examples/resolve-hostnames.c
index ac28e7b..3f7836a 100644
--- a/examples/resolve-hostnames.c
+++ b/examples/resolve-hostnames.c
@@ -12,7 +12,7 @@
int main(int argc, char **argv)
{
- if (SDLNet_Init() < 0) {
+ if (!SDLNet_Init()) {
SDL_Log("SDLNet_Init() failed: %s", SDL_GetError());
return 1;
}
diff --git a/examples/simple-http-get.c b/examples/simple-http-get.c
index fefc9ae..151d723 100644
--- a/examples/simple-http-get.c
+++ b/examples/simple-http-get.c
@@ -13,7 +13,7 @@
int main(int argc, char **argv)
{
- if (SDLNet_Init() < 0) {
+ if (!SDLNet_Init()) {
SDL_Log("SDLNet_Init() failed: %s", SDL_GetError());
return 1;
}
@@ -34,7 +34,7 @@ int main(int argc, char **argv)
SDL_Log("Failed to create stream socket to %s: %s\n", argv[i], SDL_GetError());
} else if (SDLNet_WaitUntilConnected(sock, -1) < 0) {
SDL_Log("Failed to connect to %s: %s", argv[i], SDL_GetError());
- } else if (SDLNet_WriteToStreamSocket(sock, req, SDL_strlen(req)) < 0) {
+ } else if (!SDLNet_WriteToStreamSocket(sock, req, SDL_strlen(req))) {
SDL_Log("Failed to write to %s: %s", argv[i], SDL_GetError());
} else if (SDLNet_WaitUntilStreamSocketDrained(sock, -1) < 0) {
SDL_Log("Failed to finish write to %s: %s", argv[i], SDL_GetError());
diff --git a/examples/voipchat.c b/examples/voipchat.c
index c08504e..49e7cb9 100644
--- a/examples/voipchat.c
+++ b/examples/voipchat.c
@@ -115,7 +115,7 @@ static void mainloop(void)
SDLNet_Datagram *dgram = NULL;
int rc;
- while (((rc = SDLNet_ReceiveDatagram(sock, &dgram)) == 0) && (dgram != NULL)) {
+ while (((rc = SDLNet_ReceiveDatagram(sock, &dgram)) == true) && (dgram != NULL)) {
SDL_Log("%s: got %d-byte datagram from %s:%d", is_client ? "CLIENT" : "SERVER", (int) dgram->buflen, SDLNet_GetAddressString(dgram->addr), (int) dgram->port);
activity = true;
if (!is_client) { /* we're the server? */
@@ -349,7 +349,7 @@ int main(int argc, char **argv)
return 1;
}
- if (SDLNet_Init() < 0) {
+ if (!SDLNet_Init()) {
SDL_Log("SDLNet_Init failed: %s\n", SDL_GetError());
SDL_Quit();
return 1;
diff --git a/include/SDL3_net/SDL_net.h b/include/SDL3_net/SDL_net.h
index 324db55..6a028d8 100644
--- a/include/SDL3_net/SDL_net.h
+++ b/include/SDL3_net/SDL_net.h
@@ -59,6 +59,7 @@ extern "C" {
(SDL_NET_MAJOR_VERSION > X || SDL_NET_MINOR_VERSION >= Y) && \
(SDL_NET_MAJOR_VERSION > X || SDL_NET_MINOR_VERSION > Y || SDL_NET_MICRO_VERSION >= Z))
+
/**
* This function gets the version of the dynamically linked SDL_net library.
*
@@ -81,7 +82,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_Version(void);
* once, and won't deinitialize until SDLNet_Quit() has been called a matching
* number of times. Extra attempts to init report success.
*
- * \returns 0 on success, -1 on error; call SDL_GetError() for details.
+ * \returns true on success, false on error; call SDL_GetError() for details.
*
* \threadsafety It is safe to call this function from any thread.
*
@@ -89,7 +90,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_Version(void);
*
* \sa SDLNet_Quit
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_Init(void);
+extern SDL_DECLSPEC bool SDLCALL SDLNet_Init(void);
/**
* Deinitialize the SDL_net library.
@@ -587,7 +588,7 @@ extern SDL_DECLSPEC SDLNet_Server * SDLCALL SDLNet_CreateServer(SDLNet_Address *
* as server acceptance is the final step of connecting.
*
* This function does not block. If there are no new connections pending, this
- * function will return 0 (for success, but `*client_stream` will be set to
+ * function will return true (for success, but `*client_stream` will be set to
* NULL. This is not an error and a common condition the app should expect. In
* fact, this function should be called in a loop until this condition occurs,
* so all pending connections are accepted in a single batch.
@@ -601,7 +602,7 @@ extern SDL_DECLSPEC SDLNet_Server * SDLCALL SDLNet_CreateServer(SDLNet_Address *
* \param server the server object to check for pending connections.
* \param client_stream Will be set to a new stream socket if a connection was
* pending, NULL otherwise.
- * \returns 0 on success (even if no new connections were pending), -1 on
+ * \returns true on success (even if no new connections were pending), false on
* error; call SDL_GetError() for details.
*
* \threadsafety You should not operate on the same server from multiple
@@ -614,7 +615,7 @@ extern SDL_DECLSPEC SDLNet_Server * SDLCALL SDLNet_CreateServer(SDLNet_Address *
* \sa SDLNet_WaitUntilInputAvailable
* \sa SDLNet_DestroyStreamSocket
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_AcceptClient(SDLNet_Server *server, SDLNet_StreamSocket **client_stream);
+extern SDL_DECLSPEC bool SDLCALL SDLNet_AcceptClient(SDLNet_Server *server, SDLNet_StreamSocket **client_stream);
/**
* Dispose of a previously-created server.
@@ -718,14 +719,14 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_GetConnectionStatus(SDLNet_StreamSocket *
*
* If the connection has failed (remote side dropped us, or one of a million
* other networking failures occurred), this function will report failure by
- * returning -1. Stream sockets only report failure for unrecoverable
+ * returning false. Stream sockets only report failure for unrecoverable
* conditions; once a stream socket fails, you should assume it is no longer
* usable and should destroy it with SDL_DestroyStreamSocket().
*
* \param sock the stream socket to send data through.
* \param buf a pointer to the data to send.
* \param buflen the size of the data to send, in bytes.
- * \returns 0 if data sent or queued for transmission, -1 on failure; call
+ * \returns true if data sent or queued for transmission, false on failure; call
* SDL_GetError() for details.
*
* \threadsafety You should not operate on the same socket from multiple
@@ -739,7 +740,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_GetConnectionStatus(SDLNet_StreamSocket *
* \sa SDLNet_WaitUntilStreamSocketDrained
* \sa SDLNet_ReadFromStreamSocket
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_WriteToStreamSocket(SDLNet_StreamSocket *sock, const void *buf, int buflen);
+extern SDL_DECLSPEC bool SDLCALL SDLNet_WriteToStreamSocket(SDLNet_StreamSocket *sock, const void *buf, int buflen);
/**
* Query bytes still pending transmission on a stream socket.
@@ -1030,7 +1031,7 @@ extern SDL_DECLSPEC SDLNet_DatagramSocket * SDLCALL SDLNet_CreateDatagramSocket(
* still queued, as datagram transmission is unreliable, so you should never
* assume anything about queued data.
*
- * If there's a fatal error, this function will return -1. Datagram sockets
+ * If there's a fatal error, this function will return false. Datagram sockets
* generally won't report failures, because there is no state like a
* "connection" to fail at this level, but may report failure for
* unrecoverable system-level conditions; once a datagram socket fails, you
@@ -1042,7 +1043,7 @@ extern SDL_DECLSPEC SDLNet_DatagramSocket * SDLCALL SDLNet_CreateDatagramSocket(
* \param port the address port.
* \param buf a pointer to the data to send as a single packet.
* \param buflen the size of the data to send, in bytes.
- * \returns 0 if data sent or queued for transmission, -1 on failure; call
+ * \returns true if data sent or queued for transmission, false on failure; call
* SDL_GetError() for details.
*
* \threadsafety You should not operate on the same socket from multiple
@@ -1054,7 +1055,7 @@ extern SDL_DECLSPEC SDLNet_DatagramSocket * SDLCALL SDLNet_CreateDatagramSocket(
*
* \sa SDLNet_ReceiveDatagram
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *address, Uint16 port, const void *buf, int buflen);
+extern SDL_DECLSPEC bool SDLCALL SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *address, Uint16 port, const void *buf, int buflen);
/**
@@ -1081,7 +1082,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_SendDatagram(SDLNet_DatagramSocket *sock,
* reply to. Even if you aren't acting as a "server," packets can still arrive
* at your socket if someone sends one.
*
- * If there's a fatal error, this function will return -1. Datagram sockets
+ * If there's a fatal error, this function will return false. Datagram sockets
* generally won't report failures, because there is no state like a
* "connection" to fail at this level, but may report failure for
* unrecoverable system-level conditions; once a datagram socket fails, you
@@ -1090,7 +1091,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_SendDatagram(SDLNet_DatagramSocket *sock,
*
* \param sock the datagram socket to send data through.
* \param dgram a pointer to the datagram packet pointer.
- * \returns 0 if data sent or queued for transmission, -1 on failure; call
+ * \returns true if data sent or queued for transmission, false on failure; call
* SDL_GetError() for details.
*
* \threadsafety You should not operate on the same socket from multiple
@@ -1103,7 +1104,7 @@ extern SDL_DECLSPEC int SDLCALL SDLNet_SendDatagram(SDLNet_DatagramSocket *sock,
* \sa SDLNet_SendDatagram
* \sa SDLNet_DestroyDatagram
*/
-extern SDL_DECLSPEC int SDLCALL SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram);
+extern SDL_DECLSPEC bool SDLCALL SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram);
/**
* Dispose of a datagram packet previously received.
@@ -1227,6 +1228,7 @@ extern SDL_DECLSPEC void SDLCALL SDLNet_DestroyDatagramSocket(SDLNet_DatagramSoc
* \param timeout Number of milliseconds to wait for new input to become
* available. -1 to wait indefinitely, 0 to check once without
* waiting.
+ * \returns the number of items that have new input, or -1 on error.
*
* \threadsafety You should not operate on the same socket from multiple
* threads at the same time without supplying a serialization
diff --git a/src/SDL_net.c b/src/SDL_net.c
index 55b3640..3a764cb 100644
--- a/src/SDL_net.c
+++ b/src/SDL_net.c
@@ -188,6 +188,12 @@ static int SetSocketError(const char *msg, int err)
return -1;
}
+static bool SetSocketErrorBool(const char *msg, int err)
+{
+ SetSocketError(msg, err);
+ return false;
+}
+
static int SetLastSocketError(const char *msg)
{
return SetSocketError(msg, LastSocketError());
@@ -201,6 +207,12 @@ static int SetGetAddrInfoError(const char *msg, int err)
return -1;
}
+static bool SetGetAddrInfoErrorBool(const char *msg, int err)
+{
+ SetGetAddrInfoError(msg, err);
+ return false;
+}
+
// this blocks!
static int ResolveAddress(SDLNet_Address *addr)
{
@@ -366,10 +378,10 @@ static SDLNet_Address *CreateSDLNetAddrFromSockAddr(struct sockaddr *saddr, Sock
static SDL_AtomicInt initialize_count;
-int SDLNet_Init(void)
+bool SDLNet_Init(void)
{
if (SDL_AddAtomicInt(&initialize_count, 1) > 0) {
- return 0; // already initialized, call it a success.
+ return true; // already initialized, call it a success.
}
char *origerrstr = NULL;
@@ -377,7 +389,7 @@ int SDLNet_Init(void)
#ifdef _WIN32
WSADATA data;
if (WSAStartup(MAKEWORD(1, 1), &data) != 0) {
- return SetSocketError("WSAStartup() failed", LastSocketError());
+ return SetSocketErrorBool("WSAStartup() failed", LastSocketError());
}
#else
signal(SIGPIPE, SIG_IGN);
@@ -408,7 +420,7 @@ int SDLNet_Init(void)
random_seed = (int) ((unsigned int) (SDL_GetPerformanceCounter() & 0xFFFFFFFF));
- return 0; // good to go.
+ return true; // good to go.
failed:
origerrstr = SDL_strdup(SDL_GetError());
@@ -420,7 +432,7 @@ int SDLNet_Init(void)
SDL_free(origerrstr);
}
- return -1;
+ return false;
}
void SDLNet_Quit(void)
@@ -980,7 +992,7 @@ SDLNet_Server *SDLNet_CreateServer(SDLNet_Address *addr, Uint16 port)
return server;
}
-int SDLNet_AcceptClient(SDLNet_Server *server, SDLNet_StreamSocket **client_stream)
+bool SDLNet_AcceptClient(SDLNet_Server *server, SDLNet_StreamSocket **client_stream)
{
if (!client_stream) {
return SDL_InvalidParamError("client_stream");
@@ -997,7 +1009,7 @@ int SDLNet_AcceptClient(SDLNet_Server *server, SDLNet_StreamSocket **client_stre
const Socket handle = accept(server->handle, (struct sockaddr *) &from, &fromlen);
if (handle == INVALID_SOCKET) {
const int err = LastSocketError();
- return WouldBlock(err) ? 0 : SetSocketError("Failed to accept new connection", err);
+ return WouldBlock(err) ? true : SetSocketErrorBool("Failed to accept new connection", err);
}
if (MakeSocketNonblocking(handle) < 0) {
@@ -1009,20 +1021,20 @@ int SDLNet_AcceptClient(SDLNet_Server *server, SDLNet_StreamSocket **client_stre
const int gairc = getnameinfo((struct sockaddr *) &from, fromlen, NULL, 0, portbuf, sizeof (portbuf), NI_NUMERICSERV);
if (gairc != 0) {
CloseSocketHandle(handle);
- return SetGetAddrInfoError("Failed to determine port number", gairc);
+ return SetGetAddrInfoErrorBool("Failed to determine port number", gairc);
}
SDLNet_Address *fromaddr = CreateSDLNetAddrFromSockAddr((struct sockaddr *) &from, fromlen);
if (!fromaddr) {
CloseSocketHandle(handle);
- return -1; // error string was already set.
+ return false; // error string was already set.
}
SDLNet_StreamSocket *sock = (SDLNet_StreamSocket *) SDL_calloc(1, sizeof (SDLNet_StreamSocket));
if (!sock) {
SDLNet_UnrefAddress(fromaddr);
CloseSocketHandle(handle);
- return -1;
+ return false;
}
sock->socktype = SOCKETTYPE_STREAM;
@@ -1032,7 +1044,7 @@ int SDLNet_AcceptClient(SDLNet_Server *server, SDLNet_StreamSocket **client_stre
sock->status = 1; // connected
*client_stream = sock;
- return 0;
+ return true;
}
void SDLNet_DestroyServer(SDLNet_Server *server)
@@ -1092,16 +1104,16 @@ static int PumpStreamSocket(SDLNet_StreamSocket *sock)
return 0;
}
-int SDLNet_WriteToStreamSocket(SDLNet_StreamSocket *sock, const void *buf, int buflen)
+bool SDLNet_WriteToStreamSocket(SDLNet_StreamSocket *sock, const void *buf, int buflen)
{
if (PumpStreamSocket(sock) < 0) { // try to flush any queued data to the socket now, before we handle more.
- return -1;
+ return false;
} else if (buf == NULL) {
return SDL_InvalidParamError("buf");
} else if (buflen < 0) {
return SDL_InvalidParamError("buflen");
} else if (buflen == 0) {
- return 0; // nothing to do.
+ return true; // nothing to do.
}
if (sock->pending_output_len == 0) { // nothing queued? See if we can just send this without queueing.
@@ -1111,10 +1123,10 @@ int SDLNet_WriteToStreamSocket(SDLNet_StreamSocket *sock, const void *buf, int b
if (bw < 0) {
const int err = LastSocketError();
if (!WouldBlock(err)) {
- return SetSocketError("Failed to write to socket", err);
+ return SetSocketErrorBool("Failed to write to socket", err);
}
} else if (bw == buflen) { // sent the whole thing? We're good to go here.
- return 0;
+ return true;
} else /*if (bw < buflen)*/ { // partial write? We'll queue the rest.
buf = ((const Uint8 *) buf) + bw;
buflen -= (int) bw;
@@ -1143,7 +1155,7 @@ int SDLNet_WriteToStreamSocket(SDLNet_StreamSocket *sock, const void *buf, int b
SDL_memcpy(sock->pending_output_buffer + sock->pending_output_len, buf, buflen);
sock->pending_output_len += buflen;
- return 0;
+ return true;
}
int SDLNet_GetStreamSocketPendingWrites(SDLNet_StreamSocket *sock)
@@ -1368,10 +1380,10 @@ static int PumpDatagramSocket(SDLNet_DatagramSocket *sock)
}
-int SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *addr, Uint16 port, const void *buf, int buflen)
+bool SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *addr, Uint16 port, const void *buf, int buflen)
{
if (PumpDatagramSocket(sock) < 0) { // try to flush any queued data to the socket now, before we handle more.
- return -1;
+ return false;
} else if (addr == NULL) {
return SDL_InvalidParamError("address");
} else if (buf == NULL) {
@@ -1381,17 +1393,17 @@ int SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *addr, Uint1
} else if (buflen > (64*1024)) {
return SDL_SetError("buffer is too large to send in a single datagram packet");
} else if (buflen == 0) {
- return 0; // nothing to do. (!!! FIXME: but strictly speaking, a UDP packet with no payload is legal.)
+ return true; // nothing to do. (!!! FIXME: but strictly speaking, a UDP packet with no payload is legal.)
} else if (sock->percent_loss && (RandomNumberBetween(0, 100) > sock->percent_loss)) {
- return 0; // you won the percent_loss lottery. Drop this packet as if you sent it and it never arrived.
+ return true; // you won the percent_loss lottery. Drop this packet as if you sent it and it never arrived.
}
if (sock->pending_output_len == 0) { // nothing queued? See if we can just send this without queueing.
const int rc = SendOneDatagram(sock, addr, port, buf, buflen);
if (rc < 0) {
- return -1; // error string was already set in SendOneDatagram.
+ return false; // error string was already set in SendOneDatagram.
} else if (rc == 1) {
- return 0; // successfully sent.
+ return true; // successfully sent.
}
// if rc==0, it wasn't sent, because we would have blocked. Queue it for later, below.
}
@@ -1408,7 +1420,7 @@ int SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *addr, Uint1
}
void *ptr = SDL_realloc(sock->pending_output, newlen * sizeof (SDLNet_Datagram *));
if (!ptr) {
- return -1;
+ return false;
}
sock->pending_output = (SDLNet_Datagram **) ptr;
sock->pending_output_allocation = newlen;
@@ -1416,7 +1428,7 @@ int SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *addr, Uint1
SDLNet_Datagram *dgram = (SDLNet_Datagram *) SDL_malloc(sizeof (SDLNet_Datagram) + buflen);
if (!dgram) {
- return -1;
+ return false;
}
dgram->buf = (Uint8 *) (dgram+1);
@@ -1428,11 +1440,11 @@ int SDLNet_SendDatagram(SDLNet_DatagramSocket *sock, SDLNet_Address *addr, Uint1
sock->pending_output[sock->pending_output_len++] = dgram;
- return 0;
+ return true;
}
-int SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
+bool SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
{
if (!dgram) {
return SDL_InvalidParamError("dgram");
@@ -1441,7 +1453,7 @@ int SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
*dgram = NULL;
if (PumpDatagramSocket(sock) < 0) { // try to flush any queued data to the socket now, before we go further.
- return -1;
+ return false;
}
AddressStorage from;
@@ -1450,17 +1462,17 @@ int SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
const int br = recvfrom(sock->handle, (char *) sock->recv_buffer, sizeof (sock->recv_buffer), 0, (struct sockaddr *) &from, &fromlen);
if (br == SOCKET_ERROR) {
const int err = LastSocketError();
- return WouldBlock(err) ? 0 : SetSocketError("Failed to receive datagrams", err);
+ return WouldBlock(err) ? true : SetSocketErrorBool("Failed to receive datagrams", err);
} else if (sock->percent_loss && (RandomNumberBetween(0, 100) > sock->percent_loss)) {
// you won the percent_loss lottery. Drop this packet as if it never arrived.
- return 0;
+ return true;
}
char hostbuf[128];
char portbuf[16];
const int rc = getnameinfo((struct sockaddr *) &from, fromlen, hostbuf, sizeof (hostbuf), portbuf, sizeof (portbuf), NI_NUMERICHOST | NI_NUMERICSERV);
if (rc != 0) {
- return SetGetAddrInfoError("Failed to determine incoming packet's address", rc);
+ return SetGetAddrInfoErrorBool("Failed to determine incoming packet's address", rc);
}
// Cache the last X addresses we saw; if we see it again, refcount it and reuse it.
@@ -1493,7 +1505,7 @@ int SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
if (create_fromaddr) {
fromaddr = CreateSDLNetAddrFromSockAddr((struct sockaddr *) &from, fromlen);
if (!fromaddr) {
- return -1; // already set the error string.
+ return false; // already set the error string.
}
}
@@ -1502,7 +1514,7 @@ int SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
if (create_fromaddr) {
SDLNet_UnrefAddress(fromaddr);
}
- return -1;
+ return false;
}
dg->buf = (Uint8 *) (dg+1);
@@ -1520,7 +1532,7 @@ int SDLNet_ReceiveDatagram(SDLNet_DatagramSocket *sock, SDLNet_Datagram **dgram)
sock->latest_recv_addrs_idx %= SDL_arraysize(sock->latest_recv_addrs);
}
- return 0;
+ return true;
}
void SDLNet_DestroyDatagram(SDLNet_Datagram *dgram)