[PATCH] new macro: talloc_ctxdup

Stephen Gallagher sgallagh at redhat.com
Tue May 1 05:12:59 MDT 2012

On Tue, 2012-05-01 at 15:24 +1000, Andrew Bartlett wrote:
> On Mon, 2012-04-30 at 14:11 -0700, Jeremy Allison wrote:
> > On Mon, Apr 30, 2012 at 07:08:14PM +0200, Pavel Březina wrote:
> > > Hi,
> > > I'm sending a small patch that adds talloc_ctxdup(parent, context). It
> > > is an equivalent to the existing talloc_memdup() but it duplicates a
> > > talloc context and keeps its name.
> > 
> > What use do you have for such a thing ?
> Additionally, I'm concerned that doing this in talloc (rather than in
> local macros with clear purpose) may be confusing with regards to the
> talloc tree.  This new talloc object would be a duplicate in name, and
> in memory, but would not have duplicate children - which if this is a
> struct, may be pointer elements in that struct. 

This patch came out of a discussion that Pavel and I were having about
copying memory out of a talloc pool into a new context. This seemed an
expedient way to do it. Obviously as Andrew points out, you need to also
be aware of whether the children of this context are also allocated from
the pool.

Perhaps it would be better to design a talloc_steal_ext() that could be
configured to recursively move child memory out of a pool, where
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20120501/09be8dfb/attachment.pgp>

More information about the samba-technical mailing list