From: Andrew Bartlett Date: Thu, 9 Aug 2012 09:58:31 +0000 (+1000) Subject: lib/ldb: Use tdb_exists() rather than tdb_fetch()/talloc_free() X-Git-Tag: ldb-1.1.10~3 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=299fc7522858e2d7ee6c54310a4e157c8142c74f;p=thirdparty%2Fsamba.git 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 --- diff --git a/lib/ldb/ldb_tdb/ldb_search.c b/lib/ldb/ldb_tdb/ldb_search.c index 5e2050065cb..e631f7bacae 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; } /*