A new attempt at location information for decoded JSON elements #662
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 respin of the rejected #461 containing a reimplementation of the
feature in a less intrusive manner for library users keeping it disabled.
The nftables project is very interested in having this feature to provide
similar error reporting to its JSON API users as there is for non-JSON input.
This new implementation does not introduce any overhead on storage and
negligible on CPU cycles if not enabled: It then boils down to a few extra
function calls returning early after a simple variable value check.
The above is realized by storing json_t objects' location data in a hash table
indexed by the object's address. The table is initialized upon first insert,
which then registers a destructor function using atexit() to free up any data
at program exit (to avoid complaints from memory checkers like valgrind).
If an object is deleted, its corresponding hashtable entry is removed along
with it. To facilitate location data for simple values, the singleton 'true',
'false' and 'null' objects have to be turned into allocated data structures (so
they get a unique address in memory).
This MR contains five commits: