diff options
author | Simo Sorce <idra@samba.org> | 2006-11-26 03:59:01 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 14:28:34 -0500 |
commit | baa8ed20153883ba2c5cfb5211cd1255b38b6a20 (patch) | |
tree | 496b90369dbd610af548e7f94b79c8f5a8b364b8 /source4/lib/ldb | |
parent | 5bbe9101cfca7ee4bce1e6e2615e783908375817 (diff) | |
download | samba-baa8ed20153883ba2c5cfb5211cd1255b38b6a20.tar.gz samba-baa8ed20153883ba2c5cfb5211cd1255b38b6a20.tar.bz2 samba-baa8ed20153883ba2c5cfb5211cd1255b38b6a20.zip |
r19905: use ldb_dn_new_fmt() to avoid double strdups
(This used to be commit 32a6b6c75b041bf829ecf272a9b10164f7ffe12b)
Diffstat (limited to 'source4/lib/ldb')
-rw-r--r-- | source4/lib/ldb/ldb_tdb/ldb_index.c | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/source4/lib/ldb/ldb_tdb/ldb_index.c b/source4/lib/ldb/ldb_tdb/ldb_index.c index 872afb78ae..045be985a4 100644 --- a/source4/lib/ldb/ldb_tdb/ldb_index.c +++ b/source4/lib/ldb/ldb_tdb/ldb_index.c @@ -107,7 +107,6 @@ static struct ldb_dn *ltdb_index_key(struct ldb_context *ldb, const char *attr, const struct ldb_val *value) { struct ldb_dn *ret; - char *dn; struct ldb_val v; const struct ldb_attrib_handler *h; char *attr_folded; @@ -128,27 +127,17 @@ static struct ldb_dn *ltdb_index_key(struct ldb_context *ldb, if (ldb_should_b64_encode(&v)) { char *vstr = ldb_base64_encode(ldb, (char *)v.data, v.length); if (!vstr) return NULL; - dn = talloc_asprintf(ldb, "%s:%s::%s", LTDB_INDEX, attr_folded, vstr); + ret = ldb_dn_new_fmt(ldb, ldb, "%s:%s::%s", LTDB_INDEX, attr_folded, vstr); talloc_free(vstr); - if (v.data != value->data) { - talloc_free(v.data); - } - talloc_free(attr_folded); - if (dn == NULL) return NULL; - goto done; + } else { + ret = ldb_dn_new_fmt(ldb, ldb, "%s:%s:%.*s", LTDB_INDEX, attr_folded, (int)v.length, (char *)v.data); } - dn = talloc_asprintf(ldb, "%s:%s:%.*s", - LTDB_INDEX, attr_folded, (int)v.length, (char *)v.data); - if (v.data != value->data) { talloc_free(v.data); } talloc_free(attr_folded); -done: - ret = ldb_dn_new(ldb, ldb, dn); - talloc_free(dn); return ret; } |