Added bPreallocate flag to IF_SlabManager::resize().

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@662 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
ahodgkinson
2006-07-13 18:43:22 +00:00
parent ad14af3a6e
commit 65ba56e830
3 changed files with 22 additions and 10 deletions

View File

@@ -3926,6 +3926,7 @@
virtual RCODE FLMAPI resize(
FLMUINT uiNumBytes,
FLMBOOL bPreallocate,
FLMUINT * puiActualSize = NULL) = 0;
virtual void FLMAPI incrementTotalBytesAllocated(
@@ -3963,9 +3964,9 @@
FLMUINT * puiTotalBytesAllocated) = 0;
virtual void * FLMAPI allocCell(
IF_Relocator * pRelocator = NULL,
void * pvInitialData = NULL,
FLMUINT uiDataSize = 0) = 0;
IF_Relocator * pRelocator,
void * pvInitialData,
FLMUINT uiDataSize) = 0;
virtual void * FLMAPI allocCell(
IF_Relocator * pRelocator,

View File

@@ -198,6 +198,7 @@ public:
RCODE FLMAPI resize(
FLMUINT uiNumBytes,
FLMBOOL bPreallocate,
FLMUINT * puiActualSize = NULL);
void FLMAPI incrementTotalBytesAllocated(
@@ -2277,7 +2278,7 @@ RCODE FLMAPI F_SlabManager::setup(
if( uiPreallocSize)
{
if( RC_BAD( rc = resize( uiPreallocSize, NULL)))
if( RC_BAD( rc = resize( uiPreallocSize, TRUE, NULL)))
{
goto Exit;
}
@@ -2293,6 +2294,7 @@ Desc:
****************************************************************************/
RCODE FLMAPI F_SlabManager::resize(
FLMUINT uiNumBytes,
FLMBOOL bPreallocate,
FLMUINT * puiActualSize)
{
RCODE rc = NE_FLM_OK;
@@ -2350,7 +2352,7 @@ RCODE FLMAPI F_SlabManager::resize(
m_uiTotalBytesAllocated -= m_uiSlabSize;
}
}
else
else if( bPreallocate)
{
// Allocate the required number of slabs
@@ -2392,8 +2394,15 @@ RCODE FLMAPI F_SlabManager::resize(
{
*puiActualSize = m_uiTotalSlabs * m_uiSlabSize;
}
m_uiPreallocSlabs = m_uiTotalSlabs;
if( bPreallocate)
{
m_uiPreallocSlabs = m_uiTotalSlabs;
}
else
{
m_uiPreallocSlabs = 0;
}
Exit:

View File

@@ -449,7 +449,7 @@ Exit:
Desc: Truncate the file to the indicated size
******************************************************************************/
RCODE FLMAPI F_FileHdl::truncate(
FLMUINT64 uiNew64Size)
FLMUINT64 ui64NewSize)
{
RCODE rc = NE_FLM_OK;
FLMUINT64 ui64CurrentSize;
@@ -466,7 +466,7 @@ RCODE FLMAPI F_FileHdl::truncate(
goto Exit;
}
if( ftruncate( m_fd, ui64Size) == -1)
if( ftruncate( m_fd, ui64NewSize) == -1)
{
rc = f_mapPlatformError( errno, NE_FLM_TRUNCATING_FILE);
goto Exit;
@@ -675,7 +675,6 @@ RCODE F_FileHdl::lowLevelWrite(
F_FileAsyncClient * pAsyncClient = NULL;
FLMBOOL bWaitForWrite = FALSE;
FLMBYTE * pucExtendBuffer = NULL;
FLMUINT uiTotalBytesToExtend;
if( pIOBuffer && pvBuffer && pvBuffer != pIOBuffer->getBufferPtr())
{
@@ -694,6 +693,9 @@ RCODE F_FileHdl::lowLevelWrite(
if( m_bDoDirectIO && !m_numAsyncPending && m_uiExtendSize)
{
FLMUINT64 ui64CurrFileSize;
FLMUINT uiTotalBytesToExtend;
if( RC_BAD( rc = getPreWriteExtendSize( ui64WriteOffset, uiBytesToWrite,
&ui64CurrFileSize, &uiTotalBytesToExtend)))
{