Packets are referenced counted, so once you give it to enet_peer_send() that increments its reference count by 1. It deletes when reference count hits zero. Reference counts are decremented when the packet is actually sent and no longer needed on that peer.

enet_packet_create() makes a copy of the data unless you use ENET_PACKET_FLAG_NO_ALLOCATE, in which case there is no copy. enet_peer_send() never copies anything, though, which was the claim. Lee

Marc Rochel wrote:
Hi Lee,

really? I do

                                ENetPacket * packet =
enet_packet_create(p, pn, sendoptions);

                                ret = enet_peer_send(peer, channel,
packet);

and don't care about the packet or callbacks anyfurther. Also p is
deleted soon after. Maybe I'm wrong, but I thought the callback method
was added optionally. I also thought enet_packet_create copies the data.
How does it work otherwise?

Best regards
    Marc


-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Lee Salzman
Sent: Freitag, 3. April 2009 08:31
To: Discussion of the ENet library
Subject: Re: [ENet-discuss] sending a packet

ENet does not copy the data at all. It simply queues the packet into a
list.
You need to use packet->freeCallback to see when it has deleted the
packet.

Lee

Marc Rochel wrote:
Hi Daniel,

I remember a discussing a while back about this. I think the current
behavior is when you call enet_peer_send it copies the data and you
can
immediately delete yours. Somehow you can change this, but I don't
remember how so it doesn't copy but instead calls the callback when
enet
doesn't need it anymore.

Best regards
    Marc

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Daniel Aquino
Sent: Donnerstag, 2. April 2009 20:54
To: Discussion of the ENet library
Subject: Re: [ENet-discuss] sending a packet

nvm I found ENetPacket->freeCallback in the docs...

On Thu, Apr 2, 2009 at 2:07 PM, Daniel Aquino
<[email protected]> wrote:
If I create a structure to send in the data of a packet.

Can I cleanup my data after calling enet_peer_send ?

_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss
_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss


_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss
_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss


_______________________________________________
ENet-discuss mailing list
[email protected]
http://lists.cubik.org/mailman/listinfo/enet-discuss

Reply via email to