diff options
author | KUDr <KUDr@openttd.org> | 2007-01-11 17:29:39 +0000 |
---|---|---|
committer | KUDr <KUDr@openttd.org> | 2007-01-11 17:29:39 +0000 |
commit | 28e969924b9033f5132fe2ba223e2bcadd39a7ec (patch) | |
tree | d644a3831ca0947198b191fa3e4e8973d3a9786e /src/network/core | |
parent | 5675956443d4e58713a0abd8cedb4eaaaccf22d4 (diff) | |
download | openttd-28e969924b9033f5132fe2ba223e2bcadd39a7ec.tar.xz |
(svn r8066) - Codechange: MallocT(), CallocT(), ReallocT() now return the pointer to allocated memory instead of modifying the pointer given as parameter
Diffstat (limited to 'src/network/core')
-rw-r--r-- | src/network/core/packet.cpp | 3 | ||||
-rw-r--r-- | src/network/core/tcp.cpp | 2 | ||||
-rw-r--r-- | src/network/core/udp.cpp | 4 |
3 files changed, 4 insertions, 5 deletions
diff --git a/src/network/core/packet.cpp b/src/network/core/packet.cpp index 38d00d8c0..511e0c675 100644 --- a/src/network/core/packet.cpp +++ b/src/network/core/packet.cpp @@ -26,8 +26,7 @@ extern void NORETURN CDECL error(const char *str, ...); */ Packet *NetworkSend_Init(const PacketType type) { - Packet *packet; - MallocT(&packet, 1); + Packet *packet = MallocT<Packet>(1); /* An error is inplace here, because it simply means we ran out of memory. */ if (packet == NULL) error("Failed to allocate Packet"); diff --git a/src/network/core/tcp.cpp b/src/network/core/tcp.cpp index ce00335fe..98b5d8d5d 100644 --- a/src/network/core/tcp.cpp +++ b/src/network/core/tcp.cpp @@ -149,7 +149,7 @@ Packet *NetworkRecv_Packet(NetworkClientState *cs, NetworkRecvStatus *status) if (cs->socket == INVALID_SOCKET) return NULL; if (cs->packet_recv == NULL) { - MallocT(&cs->packet_recv, 1); + cs->packet_recv = MallocT<Packet>(1); if (cs->packet_recv == NULL) error("Failed to allocate packet"); /* Set pos to zero! */ cs->packet_recv->pos = 0; diff --git a/src/network/core/udp.cpp b/src/network/core/udp.cpp index 91d751fd5..0776a2c50 100644 --- a/src/network/core/udp.cpp +++ b/src/network/core/udp.cpp @@ -252,12 +252,12 @@ void NetworkRecv_NetworkGameInfo(NetworkClientState *cs, Packet *p, NetworkGameI switch (info->game_info_version) { case 4: { - GRFConfig *c, **dst = &info->grfconfig; + GRFConfig **dst = &info->grfconfig; uint i; uint num_grfs = NetworkRecv_uint8(cs, p); for (i = 0; i < num_grfs; i++) { - CallocT(&c, 1); + GRFConfig *c = CallocT<GRFConfig>(1); NetworkRecv_GRFIdentifier(cs, p, c); HandleIncomingNetworkGameInfoGRFConfig(c); |