p-net icon indicating copy to clipboard operation
p-net copied to clipboard

Added destructor for pnet_t members

Open asade89 opened this issue 4 years ago • 2 comments
trafficstars

This is a destructor for pnet_init_only(), meaning it does not free the pnet_t structure itself. It will only free the dynamically allocated members of pnet_t.

Implementing a pnet_init() destructor in addition to this would be trivial.

Seems like this has a use in tests' TearDown() function to release dynamically allocated objects.


Hello,

I wrote this patch based on discussions in this repo.

This should resolve #260 and potentially #343 (unless pnet_t is dynamically allocated in which case it needs to be free'd too).

I was not sure about your standards in naming functions, but I guessed what you would have chosen based on similiar functionality in the code base.

I also noticed you intend to restructure pnet_t therefore I kept it simple by freeing the dynamic objects and clearing their pointers. I'm clearing the pointers because that seems to be the norm in the code base.

Introducing a pnet_init() destructor is trivial, but I didn't want to expose this to your API as I don't know what your intentions are.

If there are proposals you have in mind, please let me know and I will see can be done.

I have sent a signed CLA by physical mail which should arrive this week :)

Have a good day, cheers :D

asade89 avatar Mar 29 '21 06:03 asade89

Great, thanks for your contribution! We will have a look.

pyhys avatar Mar 29 '21 07:03 pyhys

What's the status on this? Any way I can help? @pyhys

widavies avatar Jun 02 '23 22:06 widavies