mirror of
https://github.com/sqlite/sqlite.git
synced 2025-11-12 13:01:09 +03:00
Simplification to the posix_fallocate() replacement used for the
SQLITE_FCNTL_SIZE_HINT file control in the unix VFS. FossilOrigin-Name: 74934d3f60ad9f6550297410eada0f288e0123c4
This commit is contained in:
@@ -3662,18 +3662,14 @@ static int fcntlSizeHint(unixFile *pFile, i64 nByte){
|
||||
int nWrite = 0; /* Number of bytes written by seekAndWrite */
|
||||
i64 iWrite; /* Next offset to write to */
|
||||
|
||||
iWrite = ((buf.st_size + 2*nBlk - 1)/nBlk)*nBlk-1;
|
||||
iWrite = (buf.st_size/nBlk)*nBlk + nBlk - 1;
|
||||
assert( iWrite>=buf.st_size );
|
||||
assert( (iWrite/nBlk)==((buf.st_size+nBlk-1)/nBlk) );
|
||||
assert( ((iWrite+1)%nBlk)==0 );
|
||||
for(/*no-op*/; iWrite<nSize; iWrite+=nBlk ){
|
||||
for(/*no-op*/; iWrite<nSize+nBlk-1; iWrite+=nBlk ){
|
||||
if( iWrite>=nSize ) iWrite = nSize - 1;
|
||||
nWrite = seekAndWrite(pFile, iWrite, "", 1);
|
||||
if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
|
||||
}
|
||||
if( nWrite==0 || (nSize%nBlk) ){
|
||||
nWrite = seekAndWrite(pFile, nSize-1, "", 1);
|
||||
if( nWrite!=1 ) return SQLITE_IOERR_WRITE;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user