diff options
Diffstat (limited to 'src/network')
-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 | ||||
-rw-r--r-- | src/network/network_client.cpp | 3 | ||||
-rw-r--r-- | src/network/network_data.cpp | 6 | ||||
-rw-r--r-- | src/network/network_gamelist.cpp | 2 | ||||
-rw-r--r-- | src/network/network_gui.cpp | 2 | ||||
-rw-r--r-- | src/network/network_server.cpp | 3 |
8 files changed, 10 insertions, 15 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); diff --git a/src/network/network_client.cpp b/src/network/network_client.cpp index 338d076e6..9e9b5969c 100644 --- a/src/network/network_client.cpp +++ b/src/network/network_client.cpp @@ -570,8 +570,7 @@ DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_SYNC) DEF_CLIENT_RECEIVE_COMMAND(PACKET_SERVER_COMMAND) { - CommandPacket *cp; - MallocT(&cp, 1); + CommandPacket *cp = MallocT<CommandPacket>(1); cp->player = (PlayerID)NetworkRecv_uint8(MY_CLIENT, p); cp->cmd = NetworkRecv_uint32(MY_CLIENT, p); cp->p1 = NetworkRecv_uint32(MY_CLIENT, p); diff --git a/src/network/network_data.cpp b/src/network/network_data.cpp index 89011f18d..4b0166c9a 100644 --- a/src/network/network_data.cpp +++ b/src/network/network_data.cpp @@ -14,8 +14,7 @@ // Add a command to the local command queue void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp) { - CommandPacket* new_cp; - MallocT(&new_cp, 1); + CommandPacket* new_cp = MallocT<CommandPacket>(1); *new_cp = *cp; @@ -31,8 +30,7 @@ void NetworkAddCommandQueue(NetworkClientState *cs, CommandPacket *cp) // Prepare a DoCommand to be send over the network void NetworkSend_Command(TileIndex tile, uint32 p1, uint32 p2, uint32 cmd, CommandCallback *callback) { - CommandPacket *c; - MallocT(&c, 1); + CommandPacket *c = MallocT<CommandPacket>(1); byte temp_callback; c->player = _local_player; diff --git a/src/network/network_gamelist.cpp b/src/network/network_gamelist.cpp index b1b3993bb..a202769e0 100644 --- a/src/network/network_gamelist.cpp +++ b/src/network/network_gamelist.cpp @@ -26,7 +26,7 @@ NetworkGameList *NetworkGameListAddItem(uint32 ip, uint16 port) prev_item = item; } - MallocT(&item, 1); + item = MallocT<NetworkGameList>(1); memset(item, 0, sizeof(*item)); item->next = NULL; item->ip = ip; diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp index 7a6fc221b..56fad89ee 100644 --- a/src/network/network_gui.cpp +++ b/src/network/network_gui.cpp @@ -167,7 +167,7 @@ static void BuildNetworkGameList(network_ql_d *nqld) /* Create temporary array of games to use for listing */ free(nqld->sort_list); - MallocT(&nqld->sort_list, n); + nqld->sort_list = MallocT<NetworkGameList*>(n); if (nqld->sort_list == NULL) error("Could not allocate memory for the network-game-sorting-list"); nqld->l.list_length = n; diff --git a/src/network/network_server.cpp b/src/network/network_server.cpp index c7bc2069d..ed7951c41 100644 --- a/src/network/network_server.cpp +++ b/src/network/network_server.cpp @@ -793,8 +793,7 @@ DEF_SERVER_RECEIVE_COMMAND(PACKET_CLIENT_COMMAND) const NetworkClientInfo *ci; byte callback; - CommandPacket *cp; - MallocT(&cp, 1); + CommandPacket *cp = MallocT<CommandPacket>(1); // The client was never joined.. so this is impossible, right? // Ignore the packet, give the client a warning, and close his connection |