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 answer a static analysis tool, in #3764,
which complains that an allocated buffer is not
free()
just beforeexit()
.In general, this requirement is not necessary, because invoking
exit()
terminates the process, and makes the OS reclaim all its memory.I could articulate this additional requirement in a "not too heavy" way with the use of a new macro,
CONTROL_EXIT()
.But "not too heavy" is still a form of maintenance burden: whenever the code is modified, by adding, removing or changing some of these buffers, it requires some manual coordination with exit points, which is easy to let go wrong.
Besides, I wouldn't be surprised if there were some more complex scenarios left, typically across multiple levels of functions, where a call to
exit()
is made while some other buffers, inaccessible from the function, are still allocated. Tackling such issues would require a very different approach, typically forbidding the use ofexit()
, which was meant to simplify code maintenance by reducing the nb and complexity of error paths.I question the need to make the code more complex to read and maintain, just to tackle some largely theoretical issue with no practical impact on target platforms.