UDPpacket* network_packet_resize(UDPpacket* packet, int size) { int newsize = SDLNet_ResizePacket(packet, size); if (newsize < size) { std::cerr << "Failed to resize UDP packet: " << SDLNet_GetError() << "\n"; return NULL; } return packet; }
/* * network_packet_resize() - Resize the packet data to the given size * @packet: the packet to resize * @size: the new size of the packet */ UDPpacket* network_packet_resize(UDPpacket* packet, int size) { int newsize = 0; // Define the resultant size of the packet newsize = SDLNet_ResizePacket(packet, size); // Attempt to resize the packet if (newsize < size) { // If the packet could not be resized std::cerr << "Failed to resize UDP packet: " << SDLNet_GetError() << "\n"; // Output the error message return nullptr; // Return nullptr on failure } return packet; // Return the packet pointer on success }
int UdpSocket::Resize(int pSize) { return mSize = SDLNet_ResizePacket(mPacket, pSize); }