confd: fix memory leak in lydx_new_path() #63
Merged
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.
Disclaimer
This might break something. Please test your use case.
I didn't find any need for the "first" concept at all. I have tested to query the operational status for both ietf-system (confd) and ietf-interfaces (statd). Sysrepo is still able to report operational status in the same manner as before and the memory leak is fixed.
Here's what I used to test this:
sysrepocfg -X -d operational -m ietf-system
sysrepocfg -X -d operational -m ietf-interfaces
Patch
Prior to this patch, every new call to lydx_new_path() where "first" was set to 1 resulted in a memory leak of 72 bytes. Typically at least once for each sysrepo query.
The memory was allocated deep down in the lyd library, but as the parent node wasn't set (NULL) it wasn't found by sysrepo when cleaning up.
In this patch we mitigate this by simply removing the "first" concept, as it doesn't appear to be needed.