X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Ftdb2%2Ftdb1_tdb.c;h=827b4fcf093170f677c15b6f00d34d4efbd031f1;hb=4dc29a338fadeac805b369b4b0851c02f1b152c7;hp=c69c61d0c0663f85e9eac8522a0d51c6080c0db5;hpb=60210a73ec08a7b34ba637ad19e6749cf6dc1952;p=ccan diff --git a/ccan/tdb2/tdb1_tdb.c b/ccan/tdb2/tdb1_tdb.c index c69c61d0..827b4fcf 100644 --- a/ccan/tdb2/tdb1_tdb.c +++ b/ccan/tdb2/tdb1_tdb.c @@ -189,7 +189,7 @@ static TDB_DATA _tdb1_fetch(struct tdb1_context *tdb, TDB_DATA key) uint32_t hash; /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); + hash = tdb_hash(tdb, key.dptr, key.dsize); if (!(rec_ptr = tdb1_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) return tdb1_null; @@ -236,7 +236,7 @@ int tdb1_parse_record(struct tdb1_context *tdb, TDB_DATA key, uint32_t hash; /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); + hash = tdb_hash(tdb, key.dptr, key.dsize); if (!(rec_ptr = tdb1_find_lock_hash(tdb,key,hash,F_RDLCK,&rec))) { /* record not found */ @@ -270,7 +270,7 @@ static int tdb1_exists_hash(struct tdb1_context *tdb, TDB_DATA key, uint32_t has int tdb1_exists(struct tdb1_context *tdb, TDB_DATA key) { - uint32_t hash = tdb->hash_fn(&key); + uint32_t hash = tdb_hash(tdb, key.dptr, key.dsize); int ret; ret = tdb1_exists_hash(tdb, key, hash); @@ -283,7 +283,7 @@ int tdb1_do_delete(struct tdb1_context *tdb, tdb1_off_t rec_ptr, struct tdb1_rec tdb1_off_t last_ptr, i; struct tdb1_record lastrec; - if (tdb->read_only || tdb->traverse_read) return -1; + if ((tdb->flags & TDB_RDONLY) || tdb->traverse_read) return -1; if (((tdb->traverse_write != 0) && (!TDB1_DEAD(rec))) || tdb1_write_lock_record(tdb, rec_ptr) == -1) { @@ -429,7 +429,7 @@ static int tdb1_delete_hash(struct tdb1_context *tdb, TDB_DATA key, uint32_t has int tdb1_delete(struct tdb1_context *tdb, TDB_DATA key) { - uint32_t hash = tdb->hash_fn(&key); + uint32_t hash = tdb_hash(tdb, key.dptr, key.dsize); int ret; ret = tdb1_delete_hash(tdb, key, hash); @@ -601,13 +601,13 @@ int tdb1_store(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA dbuf, int flag) uint32_t hash; int ret; - if (tdb->read_only || tdb->traverse_read) { + if ((tdb->flags & TDB_RDONLY) || tdb->traverse_read) { tdb->last_error = TDB_ERR_RDONLY; return -1; } /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); + hash = tdb_hash(tdb, key.dptr, key.dsize); if (tdb1_lock(tdb, TDB1_BUCKET(hash), F_WRLCK) == -1) return -1; @@ -624,7 +624,7 @@ int tdb1_append(struct tdb1_context *tdb, TDB_DATA key, TDB_DATA new_dbuf) int ret = -1; /* find which hash bucket it is in */ - hash = tdb->hash_fn(&key); + hash = tdb_hash(tdb, key.dptr, key.dsize); if (tdb1_lock(tdb, TDB1_BUCKET(hash), F_WRLCK) == -1) return -1;