diff options
author | Lee Salzman <[email protected]> | 2012-09-11 02:28:50 +0300 |
---|---|---|
committer | Lee Salzman <[email protected]> | 2012-09-11 02:28:50 +0300 |
commit | 71b75500495d5e11ba5fbe937e421b349d3d3059 (patch) | |
tree | f135a7f63f295884ac0657aea752f9b36dc1fc30 | |
parent | be852c5d8ba1c4e097cc86d49ddc4998a486c0eb (diff) | |
download | enet-71b75500495d5e11ba5fbe937e421b349d3d3059.tar.gz enet-71b75500495d5e11ba5fbe937e421b349d3d3059.zip |
treat destroying NULL as no-op
-rw-r--r-- | host.c | 3 | ||||
-rw-r--r-- | packet.c | 3 | ||||
-rw-r--r-- | unix.c | 3 | ||||
-rw-r--r-- | win32.c | 3 |
4 files changed, 10 insertions, 2 deletions
@@ -135,6 +135,9 @@ enet_host_destroy (ENetHost * host) { ENetPeer * currentPeer; + if (host == NULL) + return; + enet_socket_destroy (host -> socket); for (currentPeer = host -> peers; @@ -55,6 +55,9 @@ enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags) void enet_packet_destroy (ENetPacket * packet) { + if (packet == NULL) + return; + if (packet -> freeCallback != NULL) (* packet -> freeCallback) (packet); if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE) && @@ -273,7 +273,8 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address) void enet_socket_destroy (ENetSocket socket) { - close (socket); + if (socket != -1) + close (socket); } int @@ -220,7 +220,8 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address) void enet_socket_destroy (ENetSocket socket) { - closesocket (socket); + if (socket != INVALID_SOCKET) + closesocket (socket); } int |