mirror of
https://github.com/lsalzman/enet
synced 2024-11-21 14:29:05 -07:00
treat destroying NULL as no-op
This commit is contained in:
parent
be852c5d8b
commit
71b7550049
4 changed files with 10 additions and 2 deletions
3
host.c
3
host.c
|
@ -135,6 +135,9 @@ enet_host_destroy (ENetHost * host)
|
||||||
{
|
{
|
||||||
ENetPeer * currentPeer;
|
ENetPeer * currentPeer;
|
||||||
|
|
||||||
|
if (host == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
enet_socket_destroy (host -> socket);
|
enet_socket_destroy (host -> socket);
|
||||||
|
|
||||||
for (currentPeer = host -> peers;
|
for (currentPeer = host -> peers;
|
||||||
|
|
3
packet.c
3
packet.c
|
@ -55,6 +55,9 @@ enet_packet_create (const void * data, size_t dataLength, enet_uint32 flags)
|
||||||
void
|
void
|
||||||
enet_packet_destroy (ENetPacket * packet)
|
enet_packet_destroy (ENetPacket * packet)
|
||||||
{
|
{
|
||||||
|
if (packet == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
if (packet -> freeCallback != NULL)
|
if (packet -> freeCallback != NULL)
|
||||||
(* packet -> freeCallback) (packet);
|
(* packet -> freeCallback) (packet);
|
||||||
if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE) &&
|
if (! (packet -> flags & ENET_PACKET_FLAG_NO_ALLOCATE) &&
|
||||||
|
|
3
unix.c
3
unix.c
|
@ -273,7 +273,8 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address)
|
||||||
void
|
void
|
||||||
enet_socket_destroy (ENetSocket socket)
|
enet_socket_destroy (ENetSocket socket)
|
||||||
{
|
{
|
||||||
close (socket);
|
if (socket != -1)
|
||||||
|
close (socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
3
win32.c
3
win32.c
|
@ -220,7 +220,8 @@ enet_socket_accept (ENetSocket socket, ENetAddress * address)
|
||||||
void
|
void
|
||||||
enet_socket_destroy (ENetSocket socket)
|
enet_socket_destroy (ENetSocket socket)
|
||||||
{
|
{
|
||||||
closesocket (socket);
|
if (socket != INVALID_SOCKET)
|
||||||
|
closesocket (socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
|
|
Loading…
Reference in a new issue