summaryrefslogtreecommitdiffhomepage
path: root/protocol.c
diff options
context:
space:
mode:
authoreihrul <eihrul>2010-05-05 23:37:06 +0000
committereihrul <eihrul>2010-05-05 23:37:06 +0000
commit41ccbd2f3f5fca4e427aa99c3b06a573eabb7853 (patch)
tree1762799b162cd88ba95c534115d2535e4d57b0a1 /protocol.c
parent2be268a77bee17ae7bf47ffbcbb4f4d68d81608d (diff)
downloadenet-41ccbd2f3f5fca4e427aa99c3b06a573eabb7853.tar.gz
enet-41ccbd2f3f5fca4e427aa99c3b06a573eabb7853.zip
propagate malloc failure
Diffstat (limited to 'protocol.c')
-rw-r--r--protocol.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/protocol.c b/protocol.c
index 47bf844..2434e20 100644
--- a/protocol.c
+++ b/protocol.c
@@ -289,6 +289,10 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
if (currentPeer >= & host -> peers [host -> peerCount])
return NULL;
+ currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel));
+ if (currentPeer -> channels == NULL)
+ return NULL;
+ currentPeer -> channelCount = channelCount;
currentPeer -> state = ENET_PEER_STATE_ACKNOWLEDGING_CONNECT;
currentPeer -> sessionID = command -> connect.sessionID;
currentPeer -> address = host -> receivedAddress;
@@ -298,8 +302,6 @@ enet_protocol_handle_connect (ENetHost * host, ENetProtocolHeader * header, ENet
currentPeer -> packetThrottleInterval = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleInterval);
currentPeer -> packetThrottleAcceleration = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleAcceleration);
currentPeer -> packetThrottleDeceleration = ENET_NET_TO_HOST_32 (command -> connect.packetThrottleDeceleration);
- currentPeer -> channels = (ENetChannel *) enet_malloc (channelCount * sizeof (ENetChannel));
- currentPeer -> channelCount = channelCount;
for (channel = currentPeer -> channels;
channel < & currentPeer -> channels [channelCount];
@@ -440,15 +442,14 @@ enet_protocol_handle_send_unsequenced (ENetHost * host, ENetPeer * peer, const E
if (peer -> unsequencedWindow [index / 32] & (1 << (index % 32)))
return 0;
- peer -> unsequencedWindow [index / 32] |= 1 << (index % 32);
-
-
packet = enet_packet_create ((const enet_uint8 *) command + sizeof (ENetProtocolSendUnsequenced),
dataLength,
ENET_PACKET_FLAG_UNSEQUENCED);
if (packet == NULL)
return -1;
-
+
+ peer -> unsequencedWindow [index / 32] |= 1 << (index % 32);
+
enet_peer_queue_incoming_command (peer, command, packet, 0);
return 0;
}