Remove EJS tests.
[sfrench/samba-autobuild/.git] / source4 / lib / tdb / common / transaction.c
index ea0e3a93f3d46c2ccd835b95a3313afb3911f987..7acda640c8d32338de6e8651971d5f848740aae6 100644 (file)
@@ -219,9 +219,12 @@ static int transaction_write(struct tdb_context *tdb, tdb_off_t off,
                uint8_t **new_blocks;
                /* expand the blocks array */
                if (tdb->transaction->blocks == NULL) {
-                       new_blocks = malloc((blk+1)*sizeof(uint8_t *));
+                       new_blocks = (uint8_t **)malloc(
+                               (blk+1)*sizeof(uint8_t *));
                } else {
-                       new_blocks = realloc(tdb->transaction->blocks, (blk+1)*sizeof(uint8_t *));
+                       new_blocks = (uint8_t **)realloc(
+                               tdb->transaction->blocks,
+                               (blk+1)*sizeof(uint8_t *));
                }
                if (new_blocks == NULL) {
                        tdb->ecode = TDB_ERR_OOM;
@@ -318,6 +321,9 @@ static int transaction_write_existing(struct tdb_context *tdb, tdb_off_t off,
 
        if (blk == tdb->transaction->num_blocks-1 &&
            off + len > tdb->transaction->last_block_size) {
+               if (off >= tdb->transaction->last_block_size) {
+                       return 0;
+               }
                len = tdb->transaction->last_block_size - off;
        }
 
@@ -557,7 +563,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t
                TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n"));
                return -1;
        }
-#ifdef MS_SYNC
+#ifdef HAVE_MMAP
        if (tdb->map_ptr) {
                tdb_off_t moffset = offset & ~(tdb->page_size-1);
                if (msync(moffset + (char *)tdb->map_ptr,