summaryrefslogtreecommitdiff
path: root/source4/lib/ldb/common
diff options
context:
space:
mode:
authorSimo Sorce <idra@samba.org>2006-11-23 22:11:47 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 14:28:28 -0500
commit5ab439893b4628cb195801018b36504bac5ee062 (patch)
treedbfa9a56c32a48960e4e84465293fc8799caa1df /source4/lib/ldb/common
parent353b968025f126dc1dd0c0f7ac547f7a0cb5a83d (diff)
downloadsamba-5ab439893b4628cb195801018b36504bac5ee062.tar.gz
samba-5ab439893b4628cb195801018b36504bac5ee062.tar.bz2
samba-5ab439893b4628cb195801018b36504bac5ee062.zip
r19870: Simplify code
(This used to be commit c1737f9a52d9e4d118f969a0953a458188143d0d)
Diffstat (limited to 'source4/lib/ldb/common')
-rw-r--r--source4/lib/ldb/common/ldb_dn.c36
1 files changed, 11 insertions, 25 deletions
diff --git a/source4/lib/ldb/common/ldb_dn.c b/source4/lib/ldb/common/ldb_dn.c
index fff70a883f..163b09b611 100644
--- a/source4/lib/ldb/common/ldb_dn.c
+++ b/source4/lib/ldb/common/ldb_dn.c
@@ -62,7 +62,6 @@ struct ldb_dn {
bool special;
bool invalid;
- bool valid_lin;
bool valid_comp;
bool valid_case;
@@ -102,8 +101,6 @@ struct ldb_dn *ldb_dn_new(void *mem_ctx, struct ldb_context *ldb, const char *st
}
LDB_DN_NULL_FAILED(dn->linearized);
- dn->valid_lin = true;
-
return dn;
failed:
@@ -140,8 +137,6 @@ struct ldb_dn *ldb_dn_new_fmt(void *mem_ctx, struct ldb_context *ldb, const char
}
dn->linearized = strdn;
- dn->valid_lin = true;
-
return dn;
failed:
@@ -230,7 +225,7 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
return true;
}
- if ( ! dn->valid_lin) {
+ if ( ! dn->linearized) {
return false;
}
@@ -534,7 +529,7 @@ const char *ldb_dn_get_linearized(struct ldb_dn *dn)
if ( ! dn || ( dn->invalid)) return NULL;
- if (dn->valid_lin) return dn->linearized;
+ if (dn->linearized) return dn->linearized;
if ( ! dn->valid_comp) {
dn->invalid = true;
@@ -544,7 +539,6 @@ const char *ldb_dn_get_linearized(struct ldb_dn *dn)
if (dn->comp_num == 0) {
dn->linearized = talloc_strdup(dn, "");
if ( ! dn->linearized) return NULL;
- dn->valid_lin = true;
return dn->linearized;
}
@@ -576,8 +570,6 @@ const char *ldb_dn_get_linearized(struct ldb_dn *dn)
*(--d) = '\0';
- dn->valid_lin = true;
-
/* don't waste more memory than necessary */
dn->linearized = talloc_realloc(dn, dn->linearized, char, (d - dn->linearized + 1));
@@ -714,7 +706,7 @@ int ldb_dn_compare_base(struct ldb_dn *base, struct ldb_dn *dn)
if ( ! dn || dn->invalid) return -1;
if (( ! base->valid_case) || ( ! dn->valid_case)) {
- if (base->valid_lin && dn->valid_lin) {
+ if (base->linearized && dn->linearized) {
/* try with a normal compare first, if we are lucky
* we will avoid exploding and casfolding */
int dif;
@@ -785,7 +777,7 @@ int ldb_dn_compare(struct ldb_dn *dn0, struct ldb_dn *dn1)
if (( ! dn0) || dn0->invalid || ! dn1 || dn1->invalid) return -1;
if (( ! dn0->valid_case) || ( ! dn1->valid_case)) {
- if (dn0->valid_lin && dn1->valid_lin) {
+ if (dn0->linearized && dn1->linearized) {
/* try with a normal compare first, if we are lucky
* we will avoid exploding and casfolding */
if (strcmp(dn0->linearized, dn1->linearized) == 0) return 0;
@@ -918,7 +910,7 @@ struct ldb_dn *ldb_dn_copy(void *mem_ctx, struct ldb_dn *dn)
}
}
- if (dn->valid_lin) {
+ if (dn->linearized) {
new_dn->linearized = talloc_strdup(new_dn, dn->linearized);
if ( ! new_dn->linearized) {
talloc_free(new_dn);
@@ -981,7 +973,7 @@ bool ldb_dn_add_base(struct ldb_dn *dn, struct ldb_dn *base)
}
}
- if (dn->valid_lin) {
+ if (dn->linearized) {
s = ldb_dn_get_linearized(base);
if ( ! s) {
@@ -1093,7 +1085,7 @@ bool ldb_dn_add_child(struct ldb_dn *dn, struct ldb_dn *child)
}
}
- if (dn->valid_lin) {
+ if (dn->linearized) {
s = ldb_dn_get_linearized(child);
if ( ! s) {
@@ -1173,13 +1165,10 @@ bool ldb_dn_remove_base_components(struct ldb_dn *dn, unsigned int num)
LDB_FREE(dn->components[i].cf_value.data);
}
dn->valid_case = false;
- LDB_FREE(dn->casefold);
}
- if (dn->valid_lin) {
- dn->valid_lin = false;
- LDB_FREE(dn->linearized);
- }
+ LDB_FREE(dn->casefold);
+ LDB_FREE(dn->linearized);
return true;
}
@@ -1215,12 +1204,9 @@ bool ldb_dn_remove_child_components(struct ldb_dn *dn, unsigned int num)
}
dn->valid_case = false;
}
- LDB_FREE(dn->casefold);
- if (dn->valid_lin) {
- dn->valid_lin = false;
- LDB_FREE(dn->linearized);
- }
+ LDB_FREE(dn->casefold);
+ LDB_FREE(dn->linearized);
return true;
}