summaryrefslogtreecommitdiffstats
path: root/lib/tdb
diff options
context:
space:
mode:
authorMichael Adam <obnox@samba.org>2014-02-10 01:46:42 +0100
committerVolker Lendecke <vl@samba.org>2014-06-26 10:00:11 +0200
commit08a76aabe931fdb39eec9ae51ce659302268db86 (patch)
treecc167d898abd59fe195fe726fdbc1822517776cd /lib/tdb
parent87ac4ac523b68776c98fb1656d89d1eb28419fd4 (diff)
downloadsamba-08a76aabe931fdb39eec9ae51ce659302268db86.tar.gz
samba-08a76aabe931fdb39eec9ae51ce659302268db86.tar.xz
samba-08a76aabe931fdb39eec9ae51ce659302268db86.zip
tdb: reduce indentation in tdb_free() for merging left
Signed-off-by: Michael Adam <obnox@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
Diffstat (limited to 'lib/tdb')
-rw-r--r--lib/tdb/common/freelist.c41
1 files changed, 23 insertions, 18 deletions
diff --git a/lib/tdb/common/freelist.c b/lib/tdb/common/freelist.c
index 4a48c3d670..acc9f13e06 100644
--- a/lib/tdb/common/freelist.c
+++ b/lib/tdb/common/freelist.c
@@ -200,26 +200,31 @@ int tdb_free(struct tdb_context *tdb, tdb_off_t offset, struct tdb_record *rec)
left:
#endif
- if (read_record_on_left(tdb, offset, &left, &l) == 0) {
- /* If it's free, expand to include it. */
- if (l.magic == TDB_FREE_MAGIC) {
- /* we now merge the new record into the left record, rather than the other
- way around. This makes the operation O(1) instead of O(n). This change
- prevents traverse from being O(n^2) after a lot of deletes */
- l.rec_len += sizeof(*rec) + rec->rec_len;
- if (tdb_rec_write(tdb, left, &l) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_left failed at %u\n", left));
- goto fail;
- }
- if (update_tailer(tdb, left, &l) == -1) {
- TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset));
- goto fail;
- }
- tdb_unlock(tdb, -1, F_WRLCK);
- return 0;
- }
+ if (read_record_on_left(tdb, offset, &left, &l) != 0) {
+ goto update;
}
+ if (l.magic != TDB_FREE_MAGIC) {
+ goto update;
+ }
+
+ /* It's free - expand to include it. */
+
+ /* we now merge the new record into the left record, rather than the other
+ way around. This makes the operation O(1) instead of O(n). This change
+ prevents traverse from being O(n^2) after a lot of deletes */
+ l.rec_len += sizeof(*rec) + rec->rec_len;
+ if (tdb_rec_write(tdb, left, &l) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_left failed at %u\n", left));
+ goto fail;
+ }
+ if (update_tailer(tdb, left, &l) == -1) {
+ TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_free: update_tailer failed at %u\n", offset));
+ goto fail;
+ }
+ tdb_unlock(tdb, -1, F_WRLCK);
+ return 0;
+
update:
/* Now, prepend to free list */