SDLNet_ResizePacket -- resize a UDP packet.


int SDLNet_ResizePacket(UDPpacket *packet, int size)

packet A pointer to the UDPpacket to be resized.

size The new desired size, in bytes, of the data buffer to be allocated in the UDPpacket. Zero is invalid.


Resize a UDPpackets data buffer to size bytes. The old data buffer will not be retained, so the new buffer is invalid after this call.

Return Value

Returns: the new size of the data in the packet. If the number returned is less than what you asked for, that's an error.


// Resize a UDPpacket to hold 2048 bytes of data
//UDPpacket *packet;
int newsize;

newsize=SDLNet_ResizePacket(packet, 2048);
if(newsize<2048) {
    printf("SDLNet_ResizePacket: %s\n", SDLNet_GetError());
    // perhaps do something else since you didn't get the buffer you wanted
else {
    // do stuff with the resized packet

See Also

SDLNet_AllocPacket, SDLNet_AllocPacketV, SDLNet_FreePacket, UDPpacket

SDLNet_ResizePacket (last edited 2008-04-17 08:18:28 by localhost)