const on ldb_dn in ldb
simo
idra at samba.org
Wed Dec 13 12:48:50 GMT 2006
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
I am now considering of dividing ldb_sn_new*() functions in 2 classes.
Internal and for general usage. Have the internal ones not validate the
dn, but the general usage ones do.
I am still undecided on that.
Simo.
--
Simo Sorce
Samba Team GPL Compliance Officer
email: idra at samba.org
http://samba.org
More information about the samba-technical
mailing list