Add cleanup methods to complete C based ABI #3209
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.
what
Add cleanup methods to C based ABI to allow the library to be used by languages that do not link with the standard C library.
why
The C/C++ interface of libModSecurity assumes that clients that use the library are also able to link with the standard C library to free any resources allocated by libModSecurity functions and returned to the client (transferring their ownership to them).
If the client wants to build a shared library version of libModSecurity (such as .dll on Windows) and use it through the exported API, it will not be able to deallocate these resources.
This PR adds two cleanup methods to allow clients that depend just on the library's ABI to free those resources.
These methods follow the approach and terminology of existing cleanup methods in the C API (such as
msc_rules_cleanup
&msc_cleanup
) and aims to provide completeness for the lifecycle management of all objects allocated by the library.changes
void msc_rules_error_cleanup(const char *error)
msc_rules_xxx
methods.void msc_intervention_cleanup(ModSecurityIntervention *it)
url
and/orlog
members of theModSecurityIntervention
structure that may be allocated in a call tomsc_intervention
.