summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/util/util_tdb.c8
-rw-r--r--lib/util/util_tdb.h1
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/util/util_tdb.c b/lib/util/util_tdb.c
index cda8dc75b2..46dbf6d324 100644
--- a/lib/util/util_tdb.c
+++ b/lib/util/util_tdb.c
@@ -38,6 +38,14 @@ TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize)
return ret;
}
+bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2)
+{
+ if (t1.dsize != t2.dsize) {
+ return false;
+ }
+ return (memcmp(t1.dptr, t2.dptr, t1.dsize) == 0);
+}
+
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 da6378ee6a..79c46714f9 100644
--- a/lib/util/util_tdb.h
+++ b/lib/util/util_tdb.h
@@ -6,6 +6,7 @@
Make a TDB_DATA and keep the const warning in one place
****************************************************************/
TDB_DATA make_tdb_data(const uint8_t *dptr, size_t dsize);
+bool tdb_data_equal(TDB_DATA t1, TDB_DATA t2);
TDB_DATA string_tdb_data(const char *string);
TDB_DATA string_term_tdb_data(const char *string);