2 ms·
I use arenas for HTTP request handlers. The JSON built or parsed is only going to be around for the lifetime of the request. It's much simpler and faster to use
by williamcotton 4y ago
I use arenas for HTTP request handlers. The JSON built or parsed is only going to be around for the lifetime of the request. It's much simpler and faster to use an arena than to do reference counting wrapped around malloc/free.
Here's an example where in a commit I swapped in an arena:
https://github.com/williamcotton/express-c/commit/4ae53f38e3a85ed6109e5f6523cbb98aa15b20b9 https://github.com/williamcotton/express-c/commit/4ae53f38e3...
- gjulianm 4y agoI'm not saying that arena allocators are a bad tool. It seems like a very good fit for your case, where the lifetime of a request is pretty well constrained, and issues like fragmentation and overallocation won't matter too much. But still I think the OP completely misses the discussions of these aspects.