const on ldb_dn in ldb

simo idra at samba.org
Thu Dec 14 19:23:45 GMT 2006


On Thu, 2006-12-14 at 12:00 +1100, Andrew Bartlett wrote:
> On Wed, 2006-12-13 at 07:48 -0500, simo wrote:
> > On Wed, 2006-12-13 at 18:44 +1100, Andrew Bartlett wrote:
> > > Many of the ldb functions take an ldb_dn *, but this is not const in the
> > > prototype.  
> > > 
> > > For example:
> > > struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn);
> > > struct ldb_dn *ldb_dn_get_parent(void *mem_ctx, struct ldb_dn *dn);
> > > 
> > > Is there a reason for avoiding the const here?  I have functions with
> > > return a const ldb_dn, and this now causes warnings.
> > 
> > Yes, simply struct ldb_dn can never be const as the ldb_dn_* functions
> > can always manipulate it to internally explode, linearize, casefold,
> > only when really needed. The fact that we don't simply always validate
> > (which means explode it) an ldb_dn is the key for the speed improvements
> > of ldb. This means that users should validate ldb_dn's by themselves.
> > I think it would be a bit silly to have to use discard_const() just
> > everywhere in ldb_dn.c
> 
> The problem is that we now have no way to tell the difference between
> 'you may modify/free this result' and 'this is a const result that
> should not be touched'.  I understand the manipulation of private
> pointers internally makes things difficult, but it is a loss.

I know, it was not an easy choice, I am open to reconsider this
decision, want to propose a patch? :-)

Simo.

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



More information about the samba-technical mailing list