]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/tdb.c
tdb2: unify tdb1_append into tdb_append
[ccan] / ccan / tdb2 / tdb.c
index a7aa4572382b0f8b10ef03c4adc08599fd7e7293..9f3da1c01ff3363663cb14c4c6cca430367a0faa 100644 (file)
@@ -183,6 +183,12 @@ enum TDB_ERROR tdb_append(struct tdb_context *tdb,
        struct tdb_data new_dbuf;
        enum TDB_ERROR ecode;
 
+       if (tdb->flags & TDB_VERSION1) {
+               if (tdb1_append(tdb, key, dbuf) == -1)
+                       return tdb->last_error;
+               return TDB_SUCCESS;
+       }
+
        off = find_and_lock(tdb, key, F_WRLCK, &h, &rec, NULL);
        if (TDB_OFF_IS_ERR(off)) {
                return tdb->last_error = off;
@@ -248,6 +254,9 @@ enum TDB_ERROR tdb_fetch(struct tdb_context *tdb, struct tdb_data key,
        struct hash_info h;
        enum TDB_ERROR ecode;
 
+       if (tdb->flags & TDB_VERSION1)
+               return tdb1_fetch(tdb, key, data);
+
        off = find_and_lock(tdb, key, F_RDLCK, &h, &rec, NULL);
        if (TDB_OFF_IS_ERR(off)) {
                return tdb->last_error = off;