summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Bartlett <abartlet@samba.org>2012-08-09 19:58:31 +1000
committerAndrew Bartlett <abartlet@samba.org>2012-08-09 20:14:22 +1000
commit299fc7522858e2d7ee6c54310a4e157c8142c74f (patch)
tree5b9e8a60d39cca4a2f4c8c2abe5ccee3c50ba8e3 /lib
parentd799b25dd3ed0f72ee03949225ba241c5538d7d6 (diff)
downloadsamba-299fc7522858e2d7ee6c54310a4e157c8142c74f.tar.gz
samba-299fc7522858e2d7ee6c54310a4e157c8142c74f.tar.bz2
samba-299fc7522858e2d7ee6c54310a4e157c8142c74f.zip
lib/ldb: Use tdb_exists() rather than tdb_fetch()/talloc_free()
This avoids pulling the record and doing an allocation when we just want to know if it exists. Andrew Bartlett
Diffstat (limited to 'lib')
-rw-r--r--lib/ldb/ldb_tdb/ldb_search.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c
index 5e2050065c..e631f7baca 100644
--- a/lib/ldb/ldb_tdb/ldb_search.c
+++ b/lib/ldb/ldb_tdb/ldb_search.c
@@ -212,7 +212,8 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
{
void *data = ldb_module_get_private(module);
struct ltdb_private *ltdb = talloc_get_type(data, struct ltdb_private);
- TDB_DATA tdb_key, tdb_data;
+ TDB_DATA tdb_key;
+ int exists;
if (ldb_dn_is_null(dn)) {
return LDB_ERR_NO_SUCH_OBJECT;
@@ -224,14 +225,13 @@ static int ltdb_search_base(struct ldb_module *module, struct ldb_dn *dn)
return LDB_ERR_OPERATIONS_ERROR;
}
- tdb_data = tdb_fetch(ltdb->tdb, tdb_key);
+ exists = tdb_exists(ltdb->tdb, tdb_key);
talloc_free(tdb_key.dptr);
- if (!tdb_data.dptr) {
- return LDB_ERR_NO_SUCH_OBJECT;
+
+ if (exists) {
+ return LDB_SUCCESS;
}
-
- free(tdb_data.dptr);
- return LDB_SUCCESS;
+ return LDB_ERR_NO_SUCH_OBJECT;
}
/*