On 11/23/2011 10:41 AM, Phil Mayers wrote:
On 11/23/2011 01:40 PM, Alan DeKok wrote:
I don't see much point in trying to reduce the memory footprint any further. What would help is allowing arbitrary length strings, but that requires changing a *lot* of code.
One thing I wondered about a while back was using a better allocator to help with things like this. In particular, "talloc" (GPL, small, used by samba) is very nice; you can do some clever things like:
ptr = talloc(ctx, 10); sub = talloc(ptr, 10); ptr == talloc_parent(sub); /* useful in some cases */ talloc_free(ptr); /* also frees sub */
You can "break" the link if you need to move blocks around etc.
Not sure if it would help with variable-length strings per se, but it might be preferable to using a dumb allocator if implementing it.
FWIW, we've been using talloc in our SSSD (System Security Services Daemon [1]) implementation. talloc is packaged independently in Fedora. I know SSSD is being picked by Ubuntu so I expect you'll see talloc packages showing up in other distros too independent of Samba. I've worked with a number of packages which use "arenas" or "pools" for allocation like talloc, they have some very attractive aspects. [1] SSSD is a system daemon. Its primary function is to provide access to identity and authentication remote resource through a common framework that can provide caching and offline support to the system. Gives you all the wonders of remote centralized authentication (single sign-on) but a good user experience for laptops disconnected from the network, plus a ton of other features. -- John Dennis <jdennis@redhat.com> Looking to carve out IT costs? www.redhat.com/carveoutcosts/