summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-12-20 16:36:02 +0100
committerStefan Metzmacher <metze@samba.org>2013-02-05 13:18:28 +0100
commit72cd5d5ff664dc46afb3dd6a5ea45a28ef7b8591 (patch)
tree345e21bb28f13b724fa9ec8ff28b266a2c06ec79 /lib
parent71247ec4bdefb3a1b16619f7ea7404bcbafb5b60 (diff)
downloadsamba-72cd5d5ff664dc46afb3dd6a5ea45a28ef7b8591.tar.gz
samba-72cd5d5ff664dc46afb3dd6a5ea45a28ef7b8591.tar.bz2
samba-72cd5d5ff664dc46afb3dd6a5ea45a28ef7b8591.zip
tdb: Remove "header" from tdb_context
header.hash_size was the only thing we ever referenced outside of tdb_open_ex and its direct callees. So this shrinks the tdb_context by 164 bytes. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> Autobuild-User(master): Stefan Metzmacher <metze@samba.org> Autobuild-Date(master): Tue Feb 5 13:18:28 CET 2013 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb/common/check.c22
-rw-r--r--lib/tdb/common/dump.c2
-rw-r--r--lib/tdb/common/freelist.c4
-rw-r--r--lib/tdb/common/freelistcheck.c2
-rw-r--r--lib/tdb/common/io.c4
-rw-r--r--lib/tdb/common/lock.c12
-rw-r--r--lib/tdb/common/open.c39
-rw-r--r--lib/tdb/common/rescue.c6
-rw-r--r--lib/tdb/common/summary.c6
-rw-r--r--lib/tdb/common/tdb.c12
-rw-r--r--lib/tdb/common/tdb_private.h6
-rw-r--r--lib/tdb/common/transaction.c4
-rw-r--r--lib/tdb/common/traverse.c4
13 files changed, 64 insertions, 59 deletions
diff --git a/lib/tdb/common/check.c b/lib/tdb/common/check.c
index 313f55cbb0..dc38102f0c 100644
--- a/lib/tdb/common/check.c
+++ b/lib/tdb/common/check.c
@@ -50,11 +50,11 @@ static bool tdb_check_header(struct tdb_context *tdb, tdb_off_t *recovery)
if (hdr.hash_size == 0)
goto corrupt;
- if (hdr.hash_size != tdb->header.hash_size)
+ if (hdr.hash_size != tdb->hash_size)
goto corrupt;
if (hdr.recovery_start != 0 &&
- hdr.recovery_start < TDB_DATA_START(tdb->header.hash_size))
+ hdr.recovery_start < TDB_DATA_START(tdb->hash_size))
goto corrupt;
*recovery = hdr.recovery_start;
@@ -74,7 +74,7 @@ static bool tdb_check_record(struct tdb_context *tdb,
tdb_off_t tailer;
/* Check rec->next: 0 or points to record offset, aligned. */
- if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->header.hash_size)){
+ if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->hash_size)){
TDB_LOG((tdb, TDB_DEBUG_ERROR,
"Record offset %d too small next %d\n",
off, rec->next));
@@ -352,7 +352,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
goto unlock;
/* We should have the whole header, too. */
- if (tdb->map_size < TDB_DATA_START(tdb->header.hash_size)) {
+ if (tdb->map_size < TDB_DATA_START(tdb->hash_size)) {
tdb->ecode = TDB_ERR_CORRUPT;
TDB_LOG((tdb, TDB_DEBUG_ERROR, "File too short for hashes\n"));
goto unlock;
@@ -360,20 +360,20 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
/* One big malloc: pointers then bit arrays. */
hashes = (unsigned char **)calloc(
- 1, sizeof(hashes[0]) * (1+tdb->header.hash_size)
- + BITMAP_BITS / CHAR_BIT * (1+tdb->header.hash_size));
+ 1, sizeof(hashes[0]) * (1+tdb->hash_size)
+ + BITMAP_BITS / CHAR_BIT * (1+tdb->hash_size));
if (!hashes) {
tdb->ecode = TDB_ERR_OOM;
goto unlock;
}
/* Initialize pointers */
- hashes[0] = (unsigned char *)(&hashes[1+tdb->header.hash_size]);
- for (h = 1; h < 1+tdb->header.hash_size; h++)
+ hashes[0] = (unsigned char *)(&hashes[1+tdb->hash_size]);
+ for (h = 1; h < 1+tdb->hash_size; h++)
hashes[h] = hashes[h-1] + BITMAP_BITS / CHAR_BIT;
/* Freelist and hash headers are all in a row: read them. */
- for (h = 0; h < 1+tdb->header.hash_size; h++) {
+ for (h = 0; h < 1+tdb->hash_size; h++) {
if (tdb_ofs_read(tdb, FREELIST_TOP + h*sizeof(tdb_off_t),
&off) == -1)
goto free;
@@ -382,7 +382,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
}
/* For each record, read it in and check it's ok. */
- for (off = TDB_DATA_START(tdb->header.hash_size);
+ for (off = TDB_DATA_START(tdb->hash_size);
off < tdb->map_size;
off += sizeof(rec) + rec.rec_len) {
if (tdb->methods->tdb_read(tdb, off, &rec, sizeof(rec),
@@ -436,7 +436,7 @@ _PUBLIC_ int tdb_check(struct tdb_context *tdb,
/* Now, hashes should all be empty: each record exists and is referred
* to by one other. */
- for (h = 0; h < 1+tdb->header.hash_size; h++) {
+ for (h = 0; h < 1+tdb->hash_size; h++) {
unsigned int i;
for (i = 0; i < BITMAP_BITS / CHAR_BIT; i++) {
if (hashes[h][i] != 0) {
diff --git a/lib/tdb/common/dump.c b/lib/tdb/common/dump.c
index 207bb24d28..f4682fa289 100644
--- a/lib/tdb/common/dump.c
+++ b/lib/tdb/common/dump.c
@@ -83,7 +83,7 @@ static int tdb_dump_chain(struct tdb_context *tdb, int i)
_PUBLIC_ void tdb_dump_all(struct tdb_context *tdb)
{
int i;
- for (i=0;i<tdb->header.hash_size;i++) {
+ for (i=0;i<tdb->hash_size;i++) {
tdb_dump_chain(tdb, i);
}
printf("freelist:\n");
diff --git a/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c
index 0de1fb4ecf..2c58c6918f 100644
--- a/lib/tdb/common/freelist.c
+++ b/lib/tdb/common/freelist.c
@@ -139,7 +139,7 @@ left:
#endif
/* Look left */
- if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) {
+ if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->hash_size)) {
tdb_off_t left = offset - sizeof(tdb_off_t);
struct tdb_record l;
tdb_off_t leftsize;
@@ -158,7 +158,7 @@ left:
left = offset - leftsize;
if (leftsize > offset ||
- left < TDB_DATA_START(tdb->header.hash_size)) {
+ left < TDB_DATA_START(tdb->hash_size)) {
goto update;
}
diff --git a/lib/tdb/common/freelistcheck.c b/lib/tdb/common/freelistcheck.c
index ab6e78f02d..3be7cfd4ba 100644
--- a/lib/tdb/common/freelistcheck.c
+++ b/lib/tdb/common/freelistcheck.c
@@ -52,7 +52,7 @@ _PUBLIC_ int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries)
*pnum_entries = 0;
- mem_tdb = tdb_open("flval", tdb->header.hash_size,
+ mem_tdb = tdb_open("flval", tdb->hash_size,
TDB_INTERNAL, O_RDWR, 0600);
if (!mem_tdb) {
return -1;
diff --git a/lib/tdb/common/io.c b/lib/tdb/common/io.c
index 2e0a206c2c..0563635e6f 100644
--- a/lib/tdb/common/io.c
+++ b/lib/tdb/common/io.c
@@ -204,14 +204,14 @@ static void tdb_next_hash_chain(struct tdb_context *tdb, uint32_t *chain)
{
uint32_t h = *chain;
if (tdb->map_ptr) {
- for (;h < tdb->header.hash_size;h++) {
+ for (;h < tdb->hash_size;h++) {
if (0 != *(uint32_t *)(TDB_HASH_TOP(h) + (unsigned char *)tdb->map_ptr)) {
break;
}
}
} else {
uint32_t off=0;
- for (;h < tdb->header.hash_size;h++) {
+ for (;h < tdb->hash_size;h++) {
if (tdb_ofs_read(tdb, TDB_HASH_TOP(h), &off) != 0 || off != 0) {
break;
}
diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index b530c6ed5f..dadc69e8cd 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -259,7 +259,7 @@ int tdb_nest_lock(struct tdb_context *tdb, uint32_t offset, int ltype,
{
struct tdb_lock_type *new_lck;
- if (offset >= lock_offset(tdb->header.hash_size)) {
+ if (offset >= lock_offset(tdb->hash_size)) {
tdb->ecode = TDB_ERR_LOCK;
TDB_LOG((tdb, TDB_DEBUG_ERROR,"tdb_lock: invalid offset %u for ltype=%d\n",
offset, ltype));
@@ -422,8 +422,8 @@ int tdb_nest_unlock(struct tdb_context *tdb, uint32_t offset, int ltype,
return 0;
/* Sanity checks */
- if (offset >= lock_offset(tdb->header.hash_size)) {
- TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: offset %u invalid (%d)\n", offset, tdb->header.hash_size));
+ if (offset >= lock_offset(tdb->hash_size)) {
+ TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_unlock: offset %u invalid (%d)\n", offset, tdb->hash_size));
return ret;
}
@@ -588,15 +588,15 @@ int tdb_allrecord_lock(struct tdb_context *tdb, int ltype,
* It is (1) which cause the starvation problem, so we're only
* gradual for that. */
if (tdb_chainlock_gradual(tdb, ltype, flags, FREELIST_TOP,
- tdb->header.hash_size * 4) == -1) {
+ tdb->hash_size * 4) == -1) {
return -1;
}
/* Grab individual record locks. */
- if (tdb_brlock(tdb, ltype, lock_offset(tdb->header.hash_size), 0,
+ if (tdb_brlock(tdb, ltype, lock_offset(tdb->hash_size), 0,
flags) == -1) {
tdb_brunlock(tdb, ltype, FREELIST_TOP,
- tdb->header.hash_size * 4);
+ tdb->hash_size * 4);
return -1;
}
diff --git a/lib/tdb/common/open.c b/lib/tdb/common/open.c
index 6630d64eac..08b9450a1c 100644
--- a/lib/tdb/common/open.c
+++ b/lib/tdb/common/open.c
@@ -170,6 +170,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
const struct tdb_logging_context *log_ctx,
tdb_hash_func hash_fn)
{
+ struct tdb_header header;
struct tdb_context *tdb;
struct stat st;
int rev = 0, locked = 0;
@@ -179,6 +180,8 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
const char *hash_alg;
uint32_t magic1, magic2;
+ ZERO_STRUCT(header);
+
if (!(tdb = (struct tdb_context *)calloc(1, sizeof *tdb))) {
/* Can't log this */
errno = ENOMEM;
@@ -288,10 +291,11 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
if (tdb->flags & TDB_INTERNAL) {
tdb->flags |= (TDB_NOLOCK | TDB_NOMMAP);
tdb->flags &= ~TDB_CLEAR_IF_FIRST;
- if (tdb_new_database(tdb, &tdb->header, hash_size) != 0) {
+ if (tdb_new_database(tdb, &header, hash_size) != 0) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: tdb_new_database failed!"));
goto fail;
}
+ tdb->hash_size = hash_size;
goto internal;
}
@@ -325,7 +329,7 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
name, strerror(errno)));
goto fail;
}
- ret = tdb_new_database(tdb, &tdb->header, hash_size);
+ ret = tdb_new_database(tdb, &header, hash_size);
if (ret == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
"tdb_new_database failed for %s: %s\n",
@@ -350,23 +354,23 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
}
errno = 0;
- if (read(tdb->fd, &tdb->header, sizeof(tdb->header)) != sizeof(tdb->header)
- || strcmp(tdb->header.magic_food, TDB_MAGIC_FOOD) != 0) {
+ if (read(tdb->fd, &header, sizeof(header)) != sizeof(header)
+ || strcmp(header.magic_food, TDB_MAGIC_FOOD) != 0) {
if (!(open_flags & O_CREAT) ||
- tdb_new_database(tdb, &tdb->header, hash_size) == -1) {
+ tdb_new_database(tdb, &header, hash_size) == -1) {
if (errno == 0) {
errno = EIO; /* ie bad format or something */
}
goto fail;
}
rev = (tdb->flags & TDB_CONVERT);
- } else if (tdb->header.version != TDB_VERSION
- && !(rev = (tdb->header.version==TDB_BYTEREV(TDB_VERSION)))) {
+ } else if (header.version != TDB_VERSION
+ && !(rev = (header.version==TDB_BYTEREV(TDB_VERSION)))) {
/* wrong version */
errno = EIO;
goto fail;
}
- vp = (unsigned char *)&tdb->header.version;
+ vp = (unsigned char *)&header.version;
vertest = (((uint32_t)vp[0]) << 24) | (((uint32_t)vp[1]) << 16) |
(((uint32_t)vp[2]) << 8) | (uint32_t)vp[3];
tdb->flags |= (vertest==TDB_VERSION) ? TDB_BIGENDIAN : 0;
@@ -374,32 +378,33 @@ _PUBLIC_ struct tdb_context *tdb_open_ex(const char *name, int hash_size, int td
tdb->flags &= ~TDB_CONVERT;
else {
tdb->flags |= TDB_CONVERT;
- tdb_convert(&tdb->header, sizeof(tdb->header));
+ tdb_convert(&header, sizeof(header));
}
if (fstat(tdb->fd, &st) == -1)
goto fail;
- if (tdb->header.rwlocks != 0 &&
- tdb->header.rwlocks != TDB_HASH_RWLOCK_MAGIC) {
+ if (header.rwlocks != 0 &&
+ header.rwlocks != TDB_HASH_RWLOCK_MAGIC) {
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_open_ex: spinlocks no longer supported\n"));
goto fail;
}
+ tdb->hash_size = header.hash_size;
- if ((tdb->header.magic1_hash == 0) && (tdb->header.magic2_hash == 0)) {
+ if ((header.magic1_hash == 0) && (header.magic2_hash == 0)) {
/* older TDB without magic hash references */
tdb->hash_fn = tdb_old_hash;
- } else if (!check_header_hash(tdb, &tdb->header, !hash_fn,
+ } else if (!check_header_hash(tdb, &header, !hash_fn,
&magic1, &magic2)) {
TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_open_ex: "
"%s was not created with %s hash function we are using\n"
"magic1_hash[0x%08X %s 0x%08X] "
"magic2_hash[0x%08X %s 0x%08X]\n",
name, hash_alg,
- tdb->header.magic1_hash,
- (tdb->header.magic1_hash == magic1) ? "==" : "!=",
+ header.magic1_hash,
+ (header.magic1_hash == magic1) ? "==" : "!=",
magic1,
- tdb->header.magic2_hash,
- (tdb->header.magic2_hash == magic2) ? "==" : "!=",
+ header.magic2_hash,
+ (header.magic2_hash == magic2) ? "==" : "!=",
magic2));
errno = EINVAL;
goto fail;
diff --git a/lib/tdb/common/rescue.c b/lib/tdb/common/rescue.c
index 03ae8d6ae5..17e7ed8545 100644
--- a/lib/tdb/common/rescue.c
+++ b/lib/tdb/common/rescue.c
@@ -57,7 +57,7 @@ static bool looks_like_valid_record(struct tdb_context *tdb,
return false;
/* Next pointer must make some sense. */
- if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->header.hash_size))
+ if (rec->next > 0 && rec->next < TDB_DATA_START(tdb->hash_size))
return false;
if (tdb->methods->tdb_oob(tdb, rec->next, sizeof(*rec), 1))
@@ -234,7 +234,7 @@ _PUBLIC_ int tdb_rescue(struct tdb_context *tdb,
tdb->log.log_fn = logging_suppressed;
/* Now walk entire db looking for records. */
- for (off = TDB_DATA_START(tdb->header.hash_size);
+ for (off = TDB_DATA_START(tdb->hash_size);
off < tdb->map_size;
off += TDB_ALIGNMENT) {
if (tdb->methods->tdb_read(tdb, off, &rec, sizeof(rec),
@@ -249,7 +249,7 @@ _PUBLIC_ int tdb_rescue(struct tdb_context *tdb,
}
/* Walk hash chains to positive vet. */
- for (h = 0; h < 1+tdb->header.hash_size; h++) {
+ for (h = 0; h < 1+tdb->hash_size; h++) {
bool slow_chase = false;
tdb_off_t slow_off = FREELIST_TOP + h*sizeof(tdb_off_t);
diff --git a/lib/tdb/common/summary.c b/lib/tdb/common/summary.c
index 82572616e4..f4e6d2c7b4 100644
--- a/lib/tdb/common/summary.c
+++ b/lib/tdb/common/summary.c
@@ -116,7 +116,7 @@ _PUBLIC_ char *tdb_summary(struct tdb_context *tdb)
tally_init(&hash);
tally_init(&uncoal);
- for (off = TDB_DATA_START(tdb->header.hash_size);
+ for (off = TDB_DATA_START(tdb->hash_size);
off < tdb->map_size - 1;
off += sizeof(rec) + rec.rec_len) {
if (tdb->methods->tdb_read(tdb, off, &rec, sizeof(rec),
@@ -159,7 +159,7 @@ _PUBLIC_ char *tdb_summary(struct tdb_context *tdb)
if (unc > 1)
tally_add(&uncoal, unc - 1);
- for (off = 0; off < tdb->header.hash_size; off++)
+ for (off = 0; off < tdb->hash_size; off++)
tally_add(&hash, get_hash_length(tdb, off));
/* 20 is max length of a %zu. */
@@ -190,7 +190,7 @@ _PUBLIC_ char *tdb_summary(struct tdb_context *tdb)
(keys.num + freet.num + dead.num)
* (sizeof(struct tdb_record) + sizeof(uint32_t))
* 100.0 / tdb->map_size,
- tdb->header.hash_size * sizeof(tdb_off_t)
+ tdb->hash_size * sizeof(tdb_off_t)
* 100.0 / tdb->map_size);
unlock:
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index 7d1a40ea22..a2ae187f57 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -713,7 +713,7 @@ _PUBLIC_ int tdb_get_seqnum(struct tdb_context *tdb)
_PUBLIC_ int tdb_hash_size(struct tdb_context *tdb)
{
- return tdb->header.hash_size;
+ return tdb->hash_size;
}
_PUBLIC_ size_t tdb_map_size(struct tdb_context *tdb)
@@ -840,7 +840,7 @@ _PUBLIC_ int tdb_wipe_all(struct tdb_context *tdb)
}
/* wipe the hashes */
- for (i=0;i<tdb->header.hash_size;i++) {
+ for (i=0;i<tdb->hash_size;i++) {
if (tdb_ofs_write(tdb, TDB_HASH_TOP(i), &offset) == -1) {
TDB_LOG((tdb, TDB_DEBUG_FATAL,"tdb_wipe_all: failed to write hash %d\n", i));
goto failed;
@@ -857,8 +857,8 @@ _PUBLIC_ int tdb_wipe_all(struct tdb_context *tdb)
for the recovery area */
if (recovery_size == 0) {
/* the simple case - the whole file can be used as a freelist */
- data_len = (tdb->map_size - TDB_DATA_START(tdb->header.hash_size));
- if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) {
+ data_len = (tdb->map_size - TDB_DATA_START(tdb->hash_size));
+ if (tdb_free_region(tdb, TDB_DATA_START(tdb->hash_size), data_len) != 0) {
goto failed;
}
} else {
@@ -870,8 +870,8 @@ _PUBLIC_ int tdb_wipe_all(struct tdb_context *tdb)
move the recovery area or we risk subtle data
corruption
*/
- data_len = (recovery_head - TDB_DATA_START(tdb->header.hash_size));
- if (tdb_free_region(tdb, TDB_DATA_START(tdb->header.hash_size), data_len) != 0) {
+ data_len = (recovery_head - TDB_DATA_START(tdb->hash_size));
+ if (tdb_free_region(tdb, TDB_DATA_START(tdb->hash_size), data_len) != 0) {
goto failed;
}
/* and the 2nd free list entry after the recovery area - if any */
diff --git a/lib/tdb/common/tdb_private.h b/lib/tdb/common/tdb_private.h
index bbe8977bb0..406fc5f7f2 100644
--- a/lib/tdb/common/tdb_private.h
+++ b/lib/tdb/common/tdb_private.h
@@ -61,7 +61,7 @@ typedef uint32_t tdb_off_t;
#define TDB_DEAD(r) ((r)->magic == TDB_DEAD_MAGIC)
#define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r))
#define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off_t))
-#define TDB_HASHTABLE_SIZE(tdb) ((tdb->header.hash_size+1)*sizeof(tdb_off_t))
+#define TDB_HASHTABLE_SIZE(tdb) ((tdb->hash_size+1)*sizeof(tdb_off_t))
#define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + sizeof(tdb_off_t))
#define TDB_RECOVERY_HEAD offsetof(struct tdb_header, recovery_start)
#define TDB_SEQNUM_OFS offsetof(struct tdb_header, sequence_number)
@@ -114,7 +114,7 @@ void tdb_trace_2rec_retrec(struct tdb_context *tdb, const char *op,
#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); (x)=NULL;} } while(0)
#endif
-#define BUCKET(hash) ((hash) % tdb->header.hash_size)
+#define BUCKET(hash) ((hash) % tdb->hash_size)
#define DOCONV() (tdb->flags & TDB_CONVERT)
#define CONVERT(x) (DOCONV() ? tdb_convert(&x, sizeof(x)) : &x)
@@ -198,7 +198,7 @@ struct tdb_context {
int num_lockrecs;
struct tdb_lock_type *lockrecs; /* only real locks, all with count>0 */
enum TDB_ERROR ecode; /* error code for last tdb error */
- struct tdb_header header; /* a cached copy of the header */
+ uint32_t hash_size;
uint32_t flags; /* the flags passed to tdb_open */
struct tdb_traverse_lock travlocks; /* current traversal locks */
struct tdb_context *next; /* all tdbs to avoid multiple opens */
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c
index ee9beeb3d3..42289fd0f6 100644
--- a/lib/tdb/common/transaction.c
+++ b/lib/tdb/common/transaction.c
@@ -371,7 +371,7 @@ static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
static void transaction_next_hash_chain(struct tdb_context *tdb, uint32_t *chain)
{
uint32_t h = *chain;
- for (;h < tdb->header.hash_size;h++) {
+ for (;h < tdb->hash_size;h++) {
/* the +1 takes account of the freelist */
if (0 != tdb->transaction->hash_heads[h+1]) {
break;
@@ -495,7 +495,7 @@ static int _tdb_transaction_start(struct tdb_context *tdb,
/* setup a copy of the hash table heads so the hash scan in
traverse can be fast */
tdb->transaction->hash_heads = (uint32_t *)
- calloc(tdb->header.hash_size+1, sizeof(uint32_t));
+ calloc(tdb->hash_size+1, sizeof(uint32_t));
if (tdb->transaction->hash_heads == NULL) {
tdb->ecode = TDB_ERR_OOM;
goto fail;
diff --git a/lib/tdb/common/traverse.c b/lib/tdb/common/traverse.c
index 46e4be7672..a843359082 100644
--- a/lib/tdb/common/traverse.c
+++ b/lib/tdb/common/traverse.c
@@ -37,7 +37,7 @@ static tdb_off_t tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock
int want_next = (tlock->off != 0);
/* Lock each chain from the start one. */
- for (; tlock->hash < tdb->header.hash_size; tlock->hash++) {
+ for (; tlock->hash < tdb->hash_size; tlock->hash++) {
if (!tlock->off && tlock->hash != 0) {
/* this is an optimisation for the common case where
the hash chain is empty, which is particularly
@@ -68,7 +68,7 @@ static tdb_off_t tdb_next_lock(struct tdb_context *tdb, struct tdb_traverse_lock
system (testing using ldbtest).
*/
tdb->methods->next_hash_chain(tdb, &tlock->hash);
- if (tlock->hash == tdb->header.hash_size) {
+ if (tlock->hash == tdb->hash_size) {
continue;
}
}