static bool check_free_table(struct tdb_context *tdb,
tdb_off_t ftable_off,
unsigned ftable_num,
- tdb_off_t free[],
+ tdb_off_t fr[],
size_t num_free,
size_t *num_found)
{
return false;
/* FIXME: Check hash bits */
- p = asearch(&off, free, num_free, off_cmp);
+ p = asearch(&off, fr, num_free, off_cmp);
if (!p) {
tdb_logerr(tdb, TDB_ERR_CORRUPT,
TDB_DEBUG_ERROR,
for (len = 0; off + len < tdb->map_size; len++) {
char c;
- if (tdb->methods->read(tdb, off, &c, 1))
+ if (tdb->methods->tread(tdb, off, &c, 1))
return 0;
if (c != 0 && c != 0x43)
break;
static bool check_linear(struct tdb_context *tdb,
tdb_off_t **used, size_t *num_used,
- tdb_off_t **free, size_t *num_free,
+ tdb_off_t **fr, size_t *num_free,
tdb_off_t recovery)
{
tdb_off_t off;
}
/* This record should be in free lists. */
if (frec_ftable(&rec.f) != TDB_FTABLE_NONE
- && !append(free, num_free, off))
+ && !append(fr, num_free, off))
return false;
} else if (rec_magic(&rec.u) == TDB_USED_MAGIC
|| rec_magic(&rec.u) == TDB_CHAIN_MAGIC
int (*check)(TDB_DATA key, TDB_DATA data, void *private_data),
void *private_data)
{
- tdb_off_t *free = NULL, *used = NULL, ft, recovery;
+ tdb_off_t *fr = NULL, *used = NULL, ft, recovery;
size_t num_free = 0, num_used = 0, num_found = 0, num_ftables = 0;
if (tdb_allrecord_lock(tdb, F_RDLCK, TDB_LOCK_WAIT, false) != 0)
goto fail;
/* First we do a linear scan, checking all records. */
- if (!check_linear(tdb, &used, &num_used, &free, &num_free, recovery))
+ if (!check_linear(tdb, &used, &num_used, &fr, &num_free, recovery))
goto fail;
for (ft = first_ftable(tdb); ft; ft = next_ftable(tdb, ft)) {
if (ft == TDB_OFF_ERR)
goto fail;
- if (!check_free_table(tdb, ft, num_ftables, free, num_free,
+ if (!check_free_table(tdb, ft, num_ftables, fr, num_free,
&num_found))
goto fail;
num_ftables++;
tdb_allrecord_unlock(tdb, F_RDLCK);
tdb_unlock_expand(tdb, F_RDLCK);
+ free(fr);
+ free(used);
return 0;
fail:
+ free(fr);
+ free(used);
tdb_allrecord_unlock(tdb, F_RDLCK);
tdb_unlock_expand(tdb, F_RDLCK);
return -1;