r20242?

simo idra at samba.org
Tue Dec 19 13:34:19 GMT 2006


On Tue, 2006-12-19 at 16:20 +0300, Alexander Bokovoy wrote:
> simo wrote:
> > As we allocate them inside winbind_lookup_sid() I thought it to be 
> > misleading to mark them as const. I don't plan to modify them, but if
> > in future someone does I'd thought that would prevent someone to just
> >  blindly strdup them, it would be a waste.
> Speaking of allocations... With talloc() if we use some structure passed
> in to the function as a parent context we don't change it directly but
> rather modifying talloc's internal structures associated with this
> pointer. So in this case would it be safe to still mark passed pointer
> as const?

This is a bit controversial, it is a problem I have with struct ldb_dn
as well.

In some cases you logically don;t want to allow any operation and so you
would like to mark one as const, but struct ldb_dn by its nature can't
really be const as it can be internally modified by just asking for the
linearized or canonicalized strings.

> My thinking is against it -- i.e. you probably shouldn't specify const
> for arguments-pointers which you intend to use as parent context in the
> function.

I think mem context should not be marked as const.

Simo.

-- 
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org



More information about the samba-technical mailing list