Port from ctdb:
authorJeremy Allison <jra@samba.org>
Wed, 16 Jan 2008 01:20:50 +0000 (17:20 -0800)
committerJeremy Allison <jra@samba.org>
Wed, 16 Jan 2008 01:20:50 +0000 (17:20 -0800)
minor fix to transaction_write_existing: tridge.

Jeremy.

source/lib/tdb/common/transaction.c

index 0ecfb9b7ff610f9665ba7e53ae6eef78f71c98a3..ea0e3a93f3d46c2ccd835b95a3313afb3911f987 100644 (file)
@@ -316,25 +316,15 @@ static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
                return 0;
        }
 
                return 0;
        }
 
-       /* overwrite part of an existing block */
-       if (buf == NULL) {
-               memset(tdb->transaction->blocks[blk] + off, 0, len);
-       } else {
-               memcpy(tdb->transaction->blocks[blk] + off, buf, len);
-       }
-       if (blk == tdb->transaction->num_blocks-1) {
-               if (len + off > tdb->transaction->last_block_size) {
-                       tdb->transaction->last_block_size = len + off;
-               }
+       if (blk == tdb->transaction->num_blocks-1 &&
+           off + len > tdb->transaction->last_block_size) {
+               len = tdb->transaction->last_block_size - off;
        }
 
        }
 
-       return 0;
+       /* overwrite part of an existing block */
+       memcpy(tdb->transaction->blocks[blk] + off, buf, len);
 
 
-fail:
-       TDB_LOG((tdb, TDB_DEBUG_FATAL, "transaction_write: failed at off=%d len=%d\n", 
-                (blk*tdb->transaction->block_size) + off, len));
-       tdb->transaction->transaction_error = 1;
-       return -1;
+       return 0;
 }
 
 
 }