X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb2.h;h=811d9120458d3b720c670be0179a48db437c5533;hp=50903a7641bfcc409c2c26d7d74a0a1c40210d60;hb=a4393df8ed138b853b4ff212db7e1a50aba0b8c7;hpb=a97da100b00206544c7a68593b64a49f2b854f7e diff --git a/ccan/tdb2/tdb2.h b/ccan/tdb2/tdb2.h index 50903a76..811d9120 100644 --- a/ccan/tdb2/tdb2.h +++ b/ccan/tdb2/tdb2.h @@ -40,6 +40,8 @@ extern "C" { #include /* For bool */ #include +/* For memcmp */ +#include #endif #include #include @@ -208,6 +210,16 @@ enum TDB_ERROR tdb_delete(struct tdb_context *tdb, struct tdb_data key); */ bool tdb_exists(struct tdb_context *tdb, TDB_DATA key); +/** + * tdb_deq - are struct tdb_data equal? + * @a: one struct tdb_data + * @b: another struct tdb_data + */ +static inline bool tdb_deq(struct tdb_data a, struct tdb_data b) +{ + return a.dsize == b.dsize && memcmp(a.dptr, b.dptr, a.dsize) == 0; +} + /** * tdb_transaction_start - start a transaction * @tdb: the tdb context returned from tdb_open()