Added destructor for pnet_t members #390
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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