X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Fhash.c;h=f8d6b5812ebfb5307e35f3203dbe0ded9abdbde5;hb=96b169e986cda1de9ffbbdc98042e1099515ca34;hp=51874918c62ef4fb53e5581c252e8ace6301de9a;hpb=c5e3f07a30056cb7c3c380bf690f80815ca4b6b1;p=ccan diff --git a/ccan/tdb2/hash.c b/ccan/tdb2/hash.c index 51874918..f8d6b581 100644 --- a/ccan/tdb2/hash.c +++ b/ccan/tdb2/hash.c @@ -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) { - struct tdb_used_record pad, *r; + const struct tdb_used_record *r; 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); - 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; @@ -358,6 +360,7 @@ static int expand_group(struct tdb_context *tdb, struct hash_info *h) 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;