Hierarchical memory allocations are a great concept. But Samba's talloc is kind of bloated, with all the reference counting, destructors and stuff.
Here is a simple, 200-line version of just the hierarchical allocator: https://github.com/esneider/talloc