sdlNetAllocPacket function

Pointer<UDPpacket> sdlNetAllocPacket(
  1. int size
)

Allocate a single UDP packet.

This allocates a packet with size bytes of space for payload.

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

You can allocate multiple packets at once with SDLNet_AllocPacketV.

\param size the maximum number of bytes of payload this packet will contain. \returns the new packet, or NULL if the function ran out of memory.

\since This function is available since SDL_net 2.0.0.

\sa SDLNet_ResizePacket \sa SDLNet_FreePacket \sa SDLNet_AllocPacketV

extern DECLSPEC UDPpacket * SDLCALL SDLNet_AllocPacket(int size)

Implementation

Pointer<UDPpacket> sdlNetAllocPacket(int size) {
  final sdlNetAllocPacketLookupFunction = libSdl2Net.lookupFunction<
      Pointer<UDPpacket> Function(Int32 size),
      Pointer<UDPpacket> Function(int size)>('SDLNet_AllocPacket');
  return sdlNetAllocPacketLookupFunction(size);
}