ldb_search interface considered harmful

Andrew Bartlett abartlet at samba.org
Tue Jan 31 22:11:28 GMT 2006

On Tue, 2006-01-31 at 17:03 -0500, simo wrote:
> On Wed, 2006-02-01 at 07:41 +1100, Andrew Bartlett wrote:

> > The problem I have is that the default behaviour is to leak memory onto
> > the long-term context.  Everything continues to work perfectly, but
> > memory leaks.  Interfaces should be designed so that the easiest way to
> > code them is also the correct one.  I assert (by handwaving) that
> > calling both ldb_search and talloc_steal (on success) isn't the easiest
> > way to use the interface, and therefore callers will get it wrong.
> Well the memory should be all dependent on the result, so forgetting to
> free the result is the real problem. It's like passing a memory context
> and forgetting to free it.
> Are you proposing to just add a mem_ctx parm to ldb_search and
> talloc_steal in ldb_search() or are you proposing to pass down this
> mem_ctx to the backend modules through ldb_request ?

The backend modules should put the ldb_result as a child of the
ldb_request structure (I don't think they all do that right now...), and
the ldb_result should then (by talloc_steal()) be put on the caller's
supplied mem_ctx.

Andrew Bartlett

Andrew Bartlett                                http://samba.org/~abartlet/
Authentication Developer, Samba Team           http://samba.org
Student Network Administrator, Hawker College  http://hawkerc.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
Url : http://lists.samba.org/archive/samba-technical/attachments/20060201/04a6f8cb/attachment.bin

More information about the samba-technical mailing list