[PATCH] Add stackframes to public libsmbclient functions

Jeremy Allison jra at samba.org
Mon Nov 19 18:14:43 GMT 2007


On Mon, Nov 19, 2007 at 12:36:16PM +0100, Volker Lendecke wrote:
> As we use talloc_tos() in inner libsmbclient/ functions more and more, we need
> to make sure not to create memleaks by not free'ing talloc stackframes. This
> patch wraps all calls in libsmbclient.c that are publically exported into a
> talloc_stackframe()/talloc_free() pair.
>
> Jeremy, Derrell, can you check this?

Ok, this patch is very clean and nice - thanks Volker,
it fixes an outstanding problem very well.

Derrell - it fixes some places where you are *already*
allocating temporary talloc contexts in the libsmbclient
code. It makes memory handling in libsmbclient consistent
and predictable. You only need to remember to call talloc_free
on exit from a libsmbclient fn. This is not an onerous
requirement to get all lower layer memory leaks fixed
and all static's removed IMHO.

It's a pre-requisite for moving towards a threaded
client library implementation which I'd really like
to do btw. (to allow a separate client context to be
simultaneously access from different threads calling
into libsmbclient).

My vote is to commit this patch. It fixes an immediate
showstopper in 3.2.0, tidies up client memory handling
and is IMHO the correct mechanism to use.

It uses the same idiom as libsmbclient itself. libsmbclient
exports a context handle to its callers that they must remember to
close/free. All this does it causes libsmbclient to handle
memory in the same way.

If it's good enough for your callers why isn't it good
enough for your code ? :-) :-).

Jeremy.


More information about the samba-technical mailing list