X-Git-Url: http://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb1_tdb.c;h=895a8c2ae59218ab43778905df0787c31a96b104;hp=384654ed941a87910a3b1c00be07a570f4cae018;hb=8bc38cb177928ef739440c32e33a8eaf23a5dd22;hpb=98c754ffe65bc335f66161d6cc8705d4ea2710ec diff --git a/ccan/tdb2/tdb1_tdb.c b/ccan/tdb2/tdb1_tdb.c index 384654ed..895a8c2a 100644 --- a/ccan/tdb2/tdb1_tdb.c +++ b/ccan/tdb2/tdb1_tdb.c @@ -201,11 +201,12 @@ static TDB_DATA _tdb1_fetch(struct tdb_context *tdb, TDB_DATA key) return ret; } -TDB_DATA tdb1_fetch(struct tdb_context *tdb, TDB_DATA key) +enum TDB_ERROR tdb1_fetch(struct tdb_context *tdb, TDB_DATA key, TDB_DATA *data) { - TDB_DATA ret = _tdb1_fetch(tdb, key); - - return ret; + *data = _tdb1_fetch(tdb, key); + if (data->dptr == NULL) + return tdb->last_error; + return TDB_SUCCESS; } /* @@ -626,6 +627,8 @@ int tdb1_append(struct tdb_context *tdb, TDB_DATA key, TDB_DATA new_dbuf) TDB_DATA dbuf; int ret = -1; + assert(tdb->flags & TDB_VERSION1); + /* find which hash bucket it is in */ hash = tdb_hash(tdb, key.dptr, key.dsize); if (tdb1_lock(tdb, TDB1_BUCKET(hash), F_WRLCK) == -1)