tdb: Move adding tailer space to tdb_find_dead
authorVolker Lendecke <vl@samba.org>
Tue, 18 Mar 2014 06:52:59 +0000 (07:52 +0100)
committerMichael Adam <obnox@samba.org>
Tue, 18 Mar 2014 12:42:10 +0000 (13:42 +0100)
This aligns the tdb_find_dead API with the tdb_allocate API and thus makes it a
bit easier to understand, at least for me.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
lib/tdb/common/tdb.c

index 8242d2bb3fd3dda7989abe5689cf37a764a6eeee..742680aab3b37fee9786fc31a152cf7190682cdb 100644 (file)
@@ -452,6 +452,8 @@ static tdb_off_t tdb_find_dead(struct tdb_context *tdb, uint32_t hash,
        tdb_off_t best_rec_ptr = 0;
        struct tdb_record best = { .rec_len = UINT32_MAX };
 
+       length += sizeof(tdb_off_t); /* tailer */
+
        /* read in the hash top */
        if (tdb_ofs_read(tdb, TDB_HASH_TOP(hash), &rec_ptr) == -1)
                return 0;
@@ -518,9 +520,8 @@ static int _tdb_store(struct tdb_context *tdb, TDB_DATA key,
                 * for key, data and tailer. If we find one, we don't have to
                 * consult the central freelist.
                 */
-               rec_ptr = tdb_find_dead(
-                       tdb, hash, &rec,
-                       key.dsize + dbuf.dsize + sizeof(tdb_off_t));
+               rec_ptr = tdb_find_dead(tdb, hash, &rec,
+                                       key.dsize + dbuf.dsize);
 
                if (rec_ptr != 0) {
                        rec.key_len = key.dsize;