#include <ccan/tdb2/lock.c>
#include <ccan/tdb2/io.c>
#include <ccan/tdb2/hash.c>
+#include <ccan/tdb2/transaction.c>
#include <ccan/tdb2/check.c>
#include <ccan/tap/tap.h>
#include "logging.h"
struct tdb_data d;
/* fetch should fail. */
- d = tdb_fetch(tdb, key);
- ok1(d.dptr == NULL);
- ok1(tdb_error(tdb) == TDB_ERR_NOEXIST);
+ ok1(tdb_fetch(tdb, key, &d) == TDB_ERR_NOEXIST);
ok1(tdb_check(tdb, NULL, NULL) == 0);
/* Insert should succeed. */
ok1(tdb_store(tdb, key, data, TDB_INSERT) == 0);
ok1(tdb_check(tdb, NULL, NULL) == 0);
/* Fetch should now work. */
- d = tdb_fetch(tdb, key);
+ ok1(tdb_fetch(tdb, key, &d) == TDB_SUCCESS);
ok1(data_equal(d, data));
+ free(d.dptr);
ok1(tdb_check(tdb, NULL, NULL) == 0);
tdb_close(tdb);
}