treat destroying NULL as no-op

This commit is contained in:
Lee Salzman 2012-09-11 02:28:50 +03:00
parent be852c5d8b
commit 71b7550049
4 changed files with 10 additions and 2 deletions

3
host.c
View file

@ -135,6 +135,9 @@ enet_host_destroy (ENetHost * host)
{
ENetPeer * currentPeer;
if (host == NULL)
return;
enet_socket_destroy (host -> socket);
for (currentPeer = host -> peers;

View file

@ -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) &&

1
unix.c
View file

@ -273,6 +273,7 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address)
void
enet_socket_destroy (ENetSocket socket)
{
if (socket != -1)
close (socket);
}

View file

@ -220,6 +220,7 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address)
void
enet_socket_destroy (ENetSocket socket)
{
if (socket != INVALID_SOCKET)
closesocket (socket);
}