[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.5.4 SDLNet_AllocPacketV

UDPpacket **SDLNet_AllocPacketV(int howmany, int size)

howmany
The number of UDPpackets to allocate.
size
Size, in bytes, of the data buffers to be allocated in the new UDPpackets.
Zero is invalid.

Create (via malloc) a vector of new UDPpackets, each with data buffers of size bytes. The new packet vector should be freed using SDLNet_FreePacketV when you are done using it. The returned vector is one entry longer than requested, for a terminating NULL.

Returns: a pointer to a new empty UDPpacket vector. NULL is returned on errors, such as out-of-memory.

 
// create a new UDPpacket vector to hold 1024 bytes of data in 10 packets
UDPpacket **packetV;

packetV=SDLNet_AllocPacketV(10, 1024);
if(!packetV) {
    printf("SDLNet_AllocPacketV: %s\n", SDLNet_GetError());
    // perhaps do something else since you can't make this packet
}
else {
    // do stuff with this new packet vector
    // SDLNet_FreePacketV this packet vector when finished with it
}

See Also:
3.5.1 SDLNet_AllocPacket, 3.5.3 SDLNet_FreePacket, 3.5.5 SDLNet_FreePacketV, 3.5.2 SDLNet_ResizePacket, 4.4 UDPpacket



This document was generated on November, 3 2009 using texi2html