I’m just listening to a talk by Rusty Russell (an excellent speaker anyway) about Tridge’s talloc. It extends the traditional malloc() mechanism by making every returned pointer effectively be a memory pool. You can allocate memory that is “attached” to an existing pointer. When a parent pointer is freed, so are its children.
There are additional functions for stealing (re-attaching) a pointer to a different parent, optional destructors, and other useful trickery.
Tridge uses talloc in Samba4, and Rusty has also uses it in various places. Good stuff.
Rusty just posted some information about his talloc talk on his blog
http://ozlabs.org/~rusty/