Wolfram A. Kraushaar <[EMAIL PROTECTED]> said: > Quoting > > http://developer.gnome.org/doc/API/2.0/glib/glib-Doubly-Linked-Lists.html > > "if list elements contain dynamically allocated memory they should be freed > first" > (which is done in line 1667)
I thought Glib had a memory pool API, but it doesn't look like it :-\ So, we should crib a memory pool API from someplace (IIRC, Timo Sirainen has a good one in Dovecot that is MIT licensed) or write our own in Glib style and send it upstream (probably a bigger project than it needs to be). Memory pools are big chunks of malloc() memory that we request from the system and then use for ourselves as needed in smaller pieces. In Apache's APR implementation (which is really, really bloated) you can also nest pools. Rather than a malloc/free pair for every string, you just make a pool, "malloc" from the pool recklessly ;-) and then when you're all done, free the entire pool back to the system. In order to effective use memory pools, we would need to visually map out the data flow within the program and figure out where we have distinct "zones" of execution that do not share data outside of that zone. That would make it a candidate for having its own memory pool; when execution reaches the zone, a new pool is created, stuff happens and memory in the pool is used, then execution leaves the zone, and since none of the data is needed outside of it, the entire pool can be freed and nobody cares whose pointers are where. I really like writing memory management and data structure stuff, so I'd be happy to write us a little pool API, or at least be in charge of using Timo's. Aaron --
