summaryrefslogtreecommitdiff
path: root/lib
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 /lib
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 'lib')
-rw-r--r--lib/util/util_tdb.c4
-rw-r--r--lib/util/util_tdb.h1
2 files changed, 5 insertions, 0 deletions
diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c
index 02c7095f66..0c30d7774d 100644
--- a/lib/util/util_tdb.c
+++ b/lib/util/util_tdb.c
@@ -46,6 +46,10 @@ bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2)
return (memcmp(t1.dptr, t2.dptr, t1.dsize) == 0);
}
+bool tdb_data_is_empty(TDB_DATA d) {
+ return (d.dsize == 0) || (d.dptr == NULL);
+}
+
TDB_DATA string_tdb_data(const char *string)
{
return make_tdb_data((const uint8_t *)string, string ? strlen(string) : 0 );
diff --git a/lib/util/util_tdb.h b/lib/util/util_tdb.h
index 2d805d7d20..3d03b990c2 100644
--- a/lib/util/util_tdb.h
+++ b/lib/util/util_tdb.h
@@ -27,6 +27,7 @@
****************************************************************/
TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize);
bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2);
+bool tdb_data_is_empty(TDB_DATA d);
TDB_DATA string_tdb_data(const char *string);
TDB_DATA string_term_tdb_data(const char *string);