summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorGregor Beck <gbeck@sernet.de>2011-11-07 09:59:37 +0100
committerMichael Adam <obnox@samba.org>2011-12-03 05:20:30 +0100
commitd74b3f941f5e28bf4a98dab6d4be25fbaab200b7 (patch)
tree3d8c95e3983380e2f7335780a74c41742a031421 /source3
parent789aa9aab2b99ae1466a67e3f505abbc67a3e7cb (diff)
downloadsamba-d74b3f941f5e28bf4a98dab6d4be25fbaab200b7.tar.gz
samba-d74b3f941f5e28bf4a98dab6d4be25fbaab200b7.tar.bz2
samba-d74b3f941f5e28bf4a98dab6d4be25fbaab200b7.zip
lib/util: factor out tdb_data_is_empty
Signed-off-by: Michael Adam <obnox@samba.org> Autobuild-User: Michael Adam <obnox@samba.org> Autobuild-Date: Sat Dec 3 05:20:30 CET 2011 on sn-devel-104
Diffstat (limited to 'source3')
-rw-r--r--source3/registry/reg_backend_db.c4
-rw-r--r--source3/utils/net_idmap_check.c17
-rw-r--r--source3/utils/net_registry_check.c4
3 files changed, 7 insertions, 18 deletions
diff --git a/source3/registry/reg_backend_db.c b/source3/registry/reg_backend_db.c
index 06251e01f9..965d121649 100644
--- a/source3/registry/reg_backend_db.c
+++ b/source3/registry/reg_backend_db.c
@@ -541,10 +541,6 @@ static bool tdb_data_read_cstr(TDB_DATA *buf, char **result)
return false;
}
-static bool tdb_data_is_empty(TDB_DATA d) {
- return (d.dptr == NULL) || (d.dsize == 0);
-}
-
static bool tdb_data_is_cstr(TDB_DATA d) {
if (tdb_data_is_empty(d) || (d.dptr[d.dsize-1] != '\0')) {
return false;
diff --git a/source3/utils/net_idmap_check.c b/source3/utils/net_idmap_check.c
index b662a85792..3f9f3f53d9 100644
--- a/source3/utils/net_idmap_check.c
+++ b/source3/utils/net_idmap_check.c
@@ -43,9 +43,6 @@ static int traverse_check(struct db_record *rec, void* data);
static char* print_data(TALLOC_CTX* mem_ctx, TDB_DATA d);
static TDB_DATA parse_data(TALLOC_CTX* mem_ctx, const char** ptr);
static TDB_DATA talloc_copy(TALLOC_CTX* mem_ctx, TDB_DATA data);
-static bool is_empty(TDB_DATA data) {
- return (data.dsize == 0) || (data.dptr == NULL);
-}
/* record *********************************************************************/
@@ -275,10 +272,10 @@ static TDB_DATA_diff unpack_diff(TDB_DATA data) {
#define DEBUG_DIFF(LEV,MEM,MSG,KEY,OLD,NEW) \
DEBUG(LEV, ("%s: %s\n", MSG, print_data(MEM, KEY))); \
- if (!is_empty(OLD)) { \
+ if (!tdb_data_is_empty(OLD)) { \
DEBUGADD(LEV, ("-%s\n", print_data(MEM, OLD))); \
} \
- if (!is_empty(NEW)) { \
+ if (!tdb_data_is_empty(NEW)) { \
DEBUGADD(LEV, ("+%s\n", print_data(MEM, NEW))); \
}
@@ -501,7 +498,7 @@ int traverse_check(struct db_record *rec, void* data) {
}
if (!tdb_data_equal(key, r->key)) {
TDB_DATA oval = fetch_record(ctx, mem, r->key);
- if (!is_empty(oval) &&
+ if (!tdb_data_is_empty(oval) &&
!tdb_data_equal(oval, r->val))
{
action = get_action(&act->record_exists,
@@ -513,7 +510,7 @@ int traverse_check(struct db_record *rec, void* data) {
}
if (is_map(r)) {
TDB_DATA okey = fetch_record(ctx, mem, r->val);
- if (!is_empty(okey) &&
+ if (!tdb_data_is_empty(okey) &&
!tdb_data_equal(okey, r->key))
{
action = get_action(&act->record_exists,
@@ -566,7 +563,7 @@ TDB_DATA talloc_copy(TALLOC_CTX* mem_ctx, TDB_DATA data) {
}
static bool is_cstr(TDB_DATA str) {
- return !is_empty(str) && str.dptr[str.dsize-1] == '\0';
+ return !tdb_data_is_empty(str) && str.dptr[str.dsize-1] == '\0';
}
static bool parse_sid (TDB_DATA str, enum DT* type, struct dom_sid* sid) {
@@ -666,7 +663,7 @@ struct record* reverse_record(struct record* in)
char* print_data(TALLOC_CTX* mem_ctx, TDB_DATA d)
{
- if (!is_empty(d)) {
+ if (!tdb_data_is_empty(d)) {
char* ret = NULL;
cbuf* ost = cbuf_new(mem_ctx);
int len = cbuf_print_quoted(ost, (const char*)d.dptr, d.dsize);
@@ -753,7 +750,7 @@ static int traverse_commit(struct db_record *diff_rec, void* data) {
DEBUG_DIFF(0, mem, "Commit", key, diff.oval, diff.nval);
- if (is_empty(diff.nval)) {
+ if (tdb_data_is_empty(diff.nval)) {
status = dbwrap_record_delete(rec);
} else {
status = dbwrap_record_store(rec, diff.nval, 0);
diff --git a/source3/utils/net_registry_check.c b/source3/utils/net_registry_check.c
index ce7032ab64..9dca2192b6 100644
--- a/source3/utils/net_registry_check.c
+++ b/source3/utils/net_registry_check.c
@@ -207,10 +207,6 @@ static bool tdb_data_read_regval(TDB_DATA *buf, struct regval *result)
return true;
}
-static bool tdb_data_is_empty(TDB_DATA d) {
- return (d.dptr == NULL) || (d.dsize == 0);
-}
-
static bool tdb_data_is_cstr(TDB_DATA d) {
if (tdb_data_is_empty(d)) {
return false;