[ENet-discuss] when to delete allocated buffers?

Jay Sprenkle jsprenkle at gmail.com
Fri Dec 18 14:48:58 PST 2009


I saw this code (in peer.c):

    outgoingCommand = (ENetOutgoingCommand *) enet_malloc (sizeof
(ENetOutgoingCommand));

but that only allocates an ENetOutgoingCommand struct that has a pointer to
the the packet:

*   ENetPacket * packet;*
} ENetOutgoingCommand;

Then it inserts the command into a linked list using  enet_list_insert().

I don't see where it allocates space for the packet it's queuing up.





On Fri, Dec 18, 2009 at 4:38 PM, Lee Salzman <lsalzman1 at cox.net> wrote:

> Packets allocate their own copy of the data, so once you send them, you
> don't need to free anything since ENet handles that itself. However, the
> packets ENet gives to you on RECEIVE events, you must remember to destroy
> them when you are done with them.
>
> Lee
>
>
> Jay Sprenkle wrote:
>
>> Good afternoon all,
>>
>> <Newbie usage question alert>
>>
>> After reading through the enet source it appears that when you send a
>> packet of data a structure containing a pointer to the data is queued up to
>> send. If I malloc() or new a buffer, fill it, then send it, how do I know
>> when I can safely delete it? I don't see an event for sent data, etc.
>>
>> Thanks!
>>
>> </Newbie usage question alert>
>>
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>



-- 
Cause united breaks guitars
http://www.youtube.com/watch?v=5YGc4zOqozo
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20091218/18c2dc90/attachment.htm>


More information about the ENet-discuss mailing list