]> git.ozlabs.org Git - ccan/blobdiff - ccan/tdb2/hash.c
tdb2: remove tdb_get()
[ccan] / ccan / tdb2 / hash.c
index 51874918c62ef4fb53e5581c252e8ace6301de9a..f8d6b5812ebfb5307e35f3203dbe0ded9abdbde5 100644 (file)
@@ -42,17 +42,19 @@ uint64_t tdb_hash(struct tdb_context *tdb, const void *ptr, size_t len)
 
 uint64_t hash_record(struct tdb_context *tdb, tdb_off_t off)
 {
 
 uint64_t hash_record(struct tdb_context *tdb, tdb_off_t off)
 {
-       struct tdb_used_record pad, *r;
+       const struct tdb_used_record *r;
        const void *key;
        uint64_t klen, hash;
 
        const void *key;
        uint64_t klen, hash;
 
-       r = tdb_get(tdb, off, &pad, sizeof(pad));
+       r = tdb_access_read(tdb, off, sizeof(*r), true);
        if (!r)
                /* FIXME */
                return 0;
 
        klen = rec_key_length(r);
        if (!r)
                /* FIXME */
                return 0;
 
        klen = rec_key_length(r);
-       key = tdb_access_read(tdb, off + sizeof(pad), klen, false);
+       tdb_access_release(tdb, r);
+
+       key = tdb_access_read(tdb, off + sizeof(*r), klen, false);
        if (!key)
                return 0;
 
        if (!key)
                return 0;
 
@@ -358,6 +360,7 @@ static int expand_group(struct tdb_context *tdb, struct hash_info *h)
        if (subhash == TDB_OFF_ERR)
                return -1;
 
        if (subhash == TDB_OFF_ERR)
                return -1;
 
+       add_stat(tdb, alloc_subhash, 1);
        if (zero_out(tdb, subhash + sizeof(struct tdb_used_record),
                     sizeof(tdb_off_t) << TDB_SUBLEVEL_HASH_BITS) == -1)
                return -1;
        if (zero_out(tdb, subhash + sizeof(struct tdb_used_record),
                     sizeof(tdb_off_t) << TDB_SUBLEVEL_HASH_BITS) == -1)
                return -1;