7 ms·
One thing that sold me on Jansson is that you can set custom allocators which work very well with the request arena. Once those allocators are set the json obje
by williamcotton 1y ago
One thing that sold me on Jansson is that you can set custom allocators which work very well with the request arena. Once those allocators are set the json objects continue to use the arena even when used in middleware. This makes memory management a cinch!
From what I can tell jq’s C lib doesn’t yet expose a way to set custom allocators.
- cryptonector 1y agoYou can set a custom allocator, but it's global. You could contribute a feature to set thread-local custom allocators -- it'd be quite easy.
- cryptonector 1y agoOh right, no, jq has a custom out-of-memory handler. But it should be trivial to extend src/jv_alloc.[ch] to let you set not just a custom nomem handler but also a custom allocator, and then you can use thread-locals in your allocator.