sdlNetResizePacket function

int sdlNetResizePacket(
  1. Pointer<UDPpacket> packet,
  2. int newsize
)

Reallocate a UDP packet's payload space.

This takes an existing packet and makes sure it can contain at least newsize bytes of space for payload.

When done with this packet, you can free it with SDLNet_FreePacket. Packets can be used multiple times; you don't have to allocate a new one for each piece of data you intend to send.

Please note that on memory allocation failure, this function will leave the existing buffer alone, and will return the original buffer size. It will not return an error value, it'll just leave the packet as it was!

Warning: Existing contents of the packet's data are lost when resizing, whether you are growing or shrinking the payload space, since SDL_net does not realloc the existing data.

\param newsize the new maximum number of bytes of payload this packet will contain. \returns the new maximum payload size, which will be unchanged from the previous if the system ran out of memory.

\since This function is available since SDL_net 2.0.0.

\sa SDLNet_AllocPacket \sa SDLNet_FreePacket

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

Implementation

int sdlNetResizePacket(Pointer<UDPpacket> packet, int newsize) {
  final sdlNetResizePacketLookupFunction = libSdl2Net.lookupFunction<
      Int32 Function(Pointer<UDPpacket> packet, Int32 newsize),
      int Function(
          Pointer<UDPpacket> packet, int newsize)>('SDLNet_ResizePacket');
  return sdlNetResizePacketLookupFunction(packet, newsize);
}