]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/test/run-11-simple-fetch.c
tdb2: change API to return the error value.
[ccan] / ccan / tdb2 / test / run-11-simple-fetch.c
index 7225d88d3f583eba758f4e90dfc84f4192bd84d5..8cd281e24fe31fc9feb78b406adc209a00ab4a9f 100644 (file)
@@ -27,16 +27,15 @@ int main(int argc, char *argv[])
                        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);
                }