Update enet_packet_destroy documentation to reflect usage#127
Update enet_packet_destroy documentation to reflect usage#127bowbahdoe wants to merge 1 commit intolsalzman:masterfrom
Conversation
… used. I was working on a project and kept getting a segfault until i read deeper into the docs to know that `enet_packet_send` takes ownership of the packet. It might be beneficial to document that nearer the destroy function, but honestly I'm not sure the best way to clarify.
|
The tutorial mentions:
It is somewhat misleading to say that enet_peer_send handles the destruction, since it merely queues the packet for sending (which is also why it can't already be destroyed). I do agree that it may be helpful to make a note about this in general. Though, people could read the tutorial as well before making up their own usage pattern. :-) |
|
It is mentioned, but at least in my case i was working through a codebase that was messy in other ways and did leak memory as time went on, so I was looking for unfreed memory already. Maybe the right thing would be to just add a comment to the functions that take ownership of the packet's memory? |
|
Current behavior in ENet 1.3.17 is:
There are several possible routes forward:
What's best? I'm happy to write my own PR for the docs. I believe that library tutorials should, in general, be rock-solid production-ready code that people should be able to readily copy-and-paste. For the record, eihrul disagreed in IRC: |
I was working on a project and kept getting a segfault until i read deeper into the docs to know that
enet_packet_sendtakes ownership of the packet. It might be beneficial to document that nearer the destroy function, but honestly I'm not sure the best way to clarify.