X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb2.h;h=d9e2d9ecb520acd4e97468676c45051e109b4dcf;hp=50903a7641bfcc409c2c26d7d74a0a1c40210d60;hb=374eb28b1e95cc3f9a3ace618f2a6623881ef5a1;hpb=a97da100b00206544c7a68593b64a49f2b854f7e diff --git a/ccan/tdb2/tdb2.h b/ccan/tdb2/tdb2.h index 50903a76..d9e2d9ec 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() @@ -588,11 +600,6 @@ union tdb_attribute { struct tdb_attribute_stats stats; }; -/** - * tdb_null - a convenient value for errors. - */ -extern struct tdb_data tdb_null; - #ifdef __cplusplus } #endif