From eb72a0095f39b4160be837b4e6b5758f5240efd9 Mon Sep 17 00:00:00 2001 From: smatz Date: Fri, 9 Oct 2009 11:03:00 +0000 Subject: (svn r17746) -Codechange: 'operator new' doesn't return NULL, NetworkSend_Init() is useless --- src/network/core/packet.cpp | 14 -------------- src/network/core/packet.h | 2 -- src/network/core/tcp.cpp | 4 +--- 3 files changed, 1 insertion(+), 19 deletions(-) (limited to 'src/network/core') diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index 7a43173f1..a70bd6ca0 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -47,20 +47,6 @@ Packet::Packet(PacketType type) this->buffer[this->size++] = type; } -/** - * Create a packet for sending - * @param type the of packet - * @return the newly created packet - */ -Packet *NetworkSend_Init(PacketType type) -{ - Packet *packet = new Packet(type); - /* An error is inplace here, because it simply means we ran out of memory. */ - if (packet == NULL) error("Failed to allocate Packet"); - - return packet; -} - /** * Writes the packet size from the raw packet from packet->size */ diff --git a/src/network/core/packet.h b/src/network/core/packet.h index 6b5442e0e..7079b927b 100644 --- a/src/network/core/packet.h +++ b/src/network/core/packet.h @@ -72,8 +72,6 @@ public: void Recv_string(char *buffer, size_t size, bool allow_newlines = false); }; -Packet *NetworkSend_Init(PacketType type); - #endif /* ENABLE_NETWORK */ #endif /* NETWORK_CORE_PACKET_H */ diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index b30e4e526..c3a7733e3 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -134,16 +134,14 @@ bool NetworkTCPSocketHandler::Send_Packets() Packet *NetworkTCPSocketHandler::Recv_Packet() { ssize_t res; - Packet *p; if (!this->IsConnected()) return NULL; if (this->packet_recv == NULL) { this->packet_recv = new Packet(this); - if (this->packet_recv == NULL) error("Failed to allocate packet"); } - p = this->packet_recv; + Packet *p = this->packet_recv; /* Read packet size */ if (p->pos < sizeof(PacketSize)) { -- cgit v1.2.3-54-g00ecf