Tao.Sdl SDK Documentation

SdlNet.SDLNet_ResizePacket Method 

Resize the data buffer in a UDPpacket

[Visual Basic]
Public Shared Function SDLNet_ResizePacket( _
   ByVal packet As IntPtr, _
   ByVal newsize As Integer _
) As IntPtr
[C#]
public static IntPtr SDLNet_ResizePacket(
   IntPtr packet,
   int newsize
);

Parameters

packet
A pointer to the UDPpacket to be resized.
newsize
The new desired size, in bytes, of the data buffer to be allocated in the UDPpacket. Zero is invalid.

Return Value

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

Remarks

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.

Binds to C-function call in SDL_net.h:

            extern DECLSPEC int SDLCALL SDLNet_ResizePacket(UDPpacket *packet, int newsize)
            

Example

            // 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 Class | Tao.Sdl Namespace | SdlNet.UDPpacket | SDLNet_AllocPacket | SDLNet_AllocPacketV | SDLNet_FreePacket