3 ms·
If we're going to put large amounts of complexity into the kernel, then why not use a pool allocator to manage string allocations? Pool allocators are low-leve
by rwmj 12y ago
If we're going to put large amounts of complexity into the kernel, then why not use a pool allocator to manage string allocations? Pool allocators are low-level enough that they you can understand what's happening when they go wrong (unlike complex GCs), but make string handling code very simple.
Example code using a pool allocator I wrote about 15 years ago:
http://git.annexia.org/?p=rws.git;a=blob;f=process_rq.c;h=a04ae91fe7fdbb99d137f83c497f16879b591ade;hb=HEAD#l200 http://git.annexia.org/?p=rws.git;a=blob;f=process_rq.c;h=a0...
- TorKlingberg 12y agoInteresting, but how are the strings free'd?
- rwmj 12y agoWhen the pool is freed, all strings in it get freed. Generally you arrange pools to be per-"request" (in a web server), but it might be per-syscall in a kernel. At the end of the syscall, all strings get freed in one go. Pools can also have parent/child relations, so when a parent pool is freed, all child pools are freed.