[PATCH] new macro: talloc_ctxdup
Andrew Bartlett
abartlet at samba.org
Tue May 1 05:26:50 MDT 2012
On Tue, 2012-05-01 at 07:12 -0400, Stephen Gallagher wrote:
> 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
> appropriate.
I'm a little confused, as talloc_steal() already moves the context and
any child memory to the new parent. What would your talloc_steal_ext()
do?
Andrew Bartlett
--
Andrew Bartlett http://samba.org/~abartlet/
Authentication Developer, Samba Team http://samba.org
More information about the samba-technical
mailing list