From d74b3f941f5e28bf4a98dab6d4be25fbaab200b7 Mon Sep 17 00:00:00 2001 From: Gregor Beck Date: Mon, 7 Nov 2011 09:59:37 +0100 Subject: lib/util: factor out tdb_data_is_empty Signed-off-by: Michael Adam Autobuild-User: Michael Adam Autobuild-Date: Sat Dec 3 05:20:30 CET 2011 on sn-devel-104 --- lib/util/util_tdb.c | 4 ++++ lib/util/util_tdb.h | 1 + 2 files changed, 5 insertions(+) (limited to 'lib') 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); -- cgit