[RFC] Making talloc_reference() safer.

Rusty Russell rusty at rustcorp.com.au
Mon Oct 24 18:52:11 MDT 2011


On Mon, 24 Oct 2011 10:52:07 +0200, Michael Adam <obnox at samba.org> wrote:
Non-text part: multipart/signed
> Volker Lendecke wrote:
> > On Mon, Oct 24, 2011 at 04:41:42PM +1030, Rusty Russell wrote:
> > > Hi all,
> > > 
> > >         git://git.samba.org/rusty/samba.git #talloc-reference-check-wip
> > > 
> > > Thus, the following patches:
> > 
> > ENOPATCH.

Oops, my bad.  I meant to paste them at the bottom, too.

> I don't understand the first patch (add talloc_may_reference) at
> least from looking at it: it declares talloc_may_reference() in
> talloc.h, but it does not define it.

You caught me: totally untested code...

The implementation is simply:

_PUBLIC_ void *talloc_may_reference(const void *ptr)
{
	struct talloc_chunk *tc;

	tc = talloc_chunk_from_ptr(ptr);
	tc->flags |= TALLOC_FLAG_MAY_REF;
	return discard_const_p(void, ptr);
}

Cheers,
Rusty.


More information about the samba-technical mailing list