svn commit: samba r23290 - in
branches: SAMBA_3_0/source/nsswitch SAMBA_3_0_26/source/nsswitch
simo
idra at samba.org
Sat Jun 2 13:53:20 GMT 2007
On Fri, 2007-06-01 at 21:58 -0700, Jeremy Allison wrote:
> On Fri, Jun 01, 2007 at 10:02:30PM -0500, Gerald (Jerry) Carter wrote:
> >
> > It's is better IMO to use the correct context pointer
> > so that in this case you can free the array
> > witout worrying about it the mem_ctx point is freed
>
> I don't know what you mean by this. Actually, either
> pointer works, it simply is a matter of taste.
I am sorry to contradict you Jeremy, but it is not a matter of taste.
If you alloc all array children on the array, then if you want to
steal/move/free the array, you have to care _only_ about the array
pointer. You don;t risk leaving behind children on the wrong context,
and maybe have them freed while you are still keeping around the parent.
> > I think Michael's original code is correct.
> > For example, this is how the struct samu* stuff
> > is done.
>
> Fair enough. We were discussing taste though
> (which is why I prefered talloc_move rather
> than talloc_steal :-).
talloc_steal/talloc_move are the reasons to not alloc everything on the
generic mem_ctx, but to build memory hierarchies that reflect structure
hierarchies :)
> > The moral of the story is "Don't mix malloc and
> > talloc".
>
> That's true enough :-)
Holy words.
Simo.
--
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org
More information about the samba-technical
mailing list