[SCM] Samba Shared Repository - branch master updated

Jelmer Vernooij jelmer at samba.org
Sun Dec 12 15:05:13 MST 2010


On Sun, 2010-12-12 at 22:50 +0100, Matthias Dieter Wallnöfer wrote:
> Hi Jelmer,
> 
> Jelmer Vernooij wrote:
> > The same goes for that macro - if it doesn't deal with proper free'ing,
> > then why not avoid it rather than rewrite the rest of the function that
> > uses it?
> >
> > discard_const_p is bad, and we should avoid it unless we really can.
> >    
> well, I agree that "discard_const_p" isn't so nice. But I think the 
> right solution (if we make use of memory contexts) would be to never 
> derive them from NULL, but from a "self" instance or kind of this or if 
> not possible (static) the LDB context.
Even if we do that then it should be as a safeguard, not as an excuse
not to call talloc_free(). 

The advantage of hanging them off NULL is that they can more easily be
found using valgrind.

If we don't free these kinds of contexts explicitly and they are
allocated as children of e.g. the ldb context then that means they will
stay around for as long as the ldb context stays around, which can be a
very long time. So in some cases this will help contain the effect of
the leak but it's by no means an alternative.

Cheers,

Jelmer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20101212/a0ca879f/attachment.pgp>


More information about the samba-technical mailing list