My advice on implementing stuff in C:
My advice on implementing stuff in C:
Posted Oct 25, 2010 22:41 UTC (Mon) by nix (subscriber, #2304)In reply to: My advice on implementing stuff in C: by mjthayer
Parent article: Russell: On C Library Implementation
You do RAII in C by wrapping everything up in opaque structures allocated by dedicated allocators and freed either by dedicated freers or by APR-style pool destructors. If you're using mempools, you can even get close to the automagic destructor calls of C++ (you still have to free a mempool, but if you free the pool the free cascades down all contained pools and all their destructors.)
