SDLNet_AllocPacketV

Name

SDLNet_AllocPacketV -- allocate a packet vector.

Synopsis

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.

Description

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.

Return Value

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

Example

// 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

SDLNet_AllocPacket, SDLNet_FreePacket, SDLNet_FreePacketV, SDLNet_ResizePacket, UDPpacket

SDLNet_AllocPacketV (last edited 2008-04-17 08:18:30 by localhost)