Moved the super-file handle into FTK and fixed various memory leaks in the FLAIM/XFLAIM unit tests.

git-svn-id: https://svn.code.sf.net/p/flaim/code/trunk@575 0109f412-320b-0410-ab79-c3e0c5ffbbe6
This commit is contained in:
ahodgkinson
2006-06-15 17:05:55 +00:00
parent 9f7ca8edd3
commit 2fabd31c06
30 changed files with 1343 additions and 1866 deletions

View File

@@ -157,8 +157,10 @@ FSTATIC RCODE flmCopyDb(
{
RCODE rc = FERR_OK;
DB_COPY_INFO DbCopyInfo;
F_SuperFileHdl SrcSFileHdl;
F_SuperFileHdl DestSFileHdl;
F_SuperFileHdl * pSrcSFileHdl = NULL;
F_SuperFileHdl * pDestSFileHdl = NULL;
F_SuperFileClient * pSrcSFileClient = NULL;
F_SuperFileClient * pDestSFileClient = NULL;
FLMUINT uiFileNumber;
FLMUINT uiHighFileNumber;
FLMUINT uiHighLogFileNumber;
@@ -215,9 +217,26 @@ FSTATIC RCODE flmCopyDb(
// Set up the super file object for the source database.
// Must at least open the control file.
if( (pSrcSFileClient = f_new F_SuperFileClient) == NULL)
{
rc = RC_SET( FERR_MEM);
goto Exit;
}
if( RC_BAD( rc = pSrcSFileClient->setup(
pszSrcDbName, pszSrcDataDir, uiDbVersion)))
{
goto Exit;
}
if( (pSrcSFileHdl = f_new F_SuperFileHdl) == NULL)
{
rc = RC_SET( FERR_MEM);
goto Exit;
}
if (RC_BAD( rc = SrcSFileHdl.setup( pszSrcDbName, pszSrcDataDir,
uiDbVersion)))
if( RC_BAD( rc = pSrcSFileHdl->setup( pSrcSFileClient)))
{
goto Exit;
}
@@ -312,9 +331,26 @@ FSTATIC RCODE flmCopyDb(
}
// Set up the super file object for the destination database.
if( (pDestSFileClient = f_new F_SuperFileClient) == NULL)
{
rc = RC_SET( FERR_MEM);
goto Exit;
}
if( RC_BAD( rc = pDestSFileClient->setup(
pszDestDbName, pszDestDataDir, uiDbVersion)))
{
goto Exit;
}
if (RC_BAD( rc = DestSFileHdl.setup( pszDestDbName, pszDestDataDir,
uiDbVersion)))
if( (pDestSFileHdl = f_new F_SuperFileHdl) == NULL)
{
rc = RC_SET( FERR_MEM);
goto Exit;
}
if( RC_BAD( rc = pDestSFileHdl->setup( pDestSFileClient)))
{
goto Exit;
}
@@ -324,8 +360,8 @@ FSTATIC RCODE flmCopyDb(
uiHighFileNumber = 0;
for (;;)
{
if ((RC_BAD( rc = SrcSFileHdl.getFileSize(
uiHighFileNumber, &ui64FileSize))) || !ui64FileSize )
if( RC_BAD( rc = pSrcSFileHdl->getFileSize(
uiHighFileNumber, &ui64FileSize)) || !ui64FileSize)
{
if (rc == FERR_IO_PATH_NOT_FOUND ||
rc == FERR_IO_INVALID_PATH ||
@@ -359,7 +395,7 @@ FSTATIC RCODE flmCopyDb(
uiHighLogFileNumber = FIRST_LOG_BLOCK_FILE_NUMBER( uiDbVersion);
for (;;)
{
if ((RC_BAD( rc = SrcSFileHdl.getFileSize(
if ((RC_BAD( rc = pSrcSFileHdl->getFileSize(
uiHighLogFileNumber, &ui64FileSize))) || !ui64FileSize)
{
if (rc == FERR_IO_PATH_NOT_FOUND ||
@@ -473,8 +509,8 @@ FSTATIC RCODE flmCopyDb(
// Close all file handles in the source and destination
SrcSFileHdl.releaseFiles( TRUE);
DestSFileHdl.releaseFiles( TRUE);
pSrcSFileHdl->releaseFiles( TRUE);
pDestSFileHdl->releaseFiles( TRUE);
// Copy the database files.
@@ -483,12 +519,12 @@ FSTATIC RCODE flmCopyDb(
// Get the source file path and destination file path.
if( RC_BAD( rc = SrcSFileHdl.getFilePath(
if( RC_BAD( rc = pSrcSFileHdl->getFilePath(
uiFileNumber, DbCopyInfo.szSrcFileName)))
{
goto Exit;
}
if( RC_BAD( rc = DestSFileHdl.getFilePath(
if( RC_BAD( rc = pDestSFileHdl->getFilePath(
uiFileNumber, DbCopyInfo.szDestFileName)))
{
goto Exit;
@@ -531,13 +567,13 @@ FSTATIC RCODE flmCopyDb(
// Get the source file path and destination file path.
if (RC_BAD( rc = SrcSFileHdl.getFilePath( uiFileNumber,
if (RC_BAD( rc = pSrcSFileHdl->getFilePath( uiFileNumber,
DbCopyInfo.szSrcFileName)))
{
goto Exit;
}
if (RC_BAD( rc = DestSFileHdl.getFilePath( uiFileNumber,
if (RC_BAD( rc = pDestSFileHdl->getFilePath( uiFileNumber,
DbCopyInfo.szDestFileName)))
{
goto Exit;
@@ -685,12 +721,12 @@ FSTATIC RCODE flmCopyDb(
// Do one final copy on the control file to copy just the first 2K
if (RC_BAD( rc = SrcSFileHdl.getFilePath( 0, DbCopyInfo.szSrcFileName)))
if (RC_BAD( rc = pSrcSFileHdl->getFilePath( 0, DbCopyInfo.szSrcFileName)))
{
goto Exit;
}
if (RC_BAD( rc = DestSFileHdl.getFilePath( 0, DbCopyInfo.szDestFileName)))
if (RC_BAD( rc = pDestSFileHdl->getFilePath( 0, DbCopyInfo.szDestFileName)))
{
goto Exit;
}
@@ -810,6 +846,26 @@ Exit:
{
f_semDestroy( &hWaitSem);
}
if( pSrcSFileHdl)
{
pSrcSFileHdl->Release();
}
if( pSrcSFileClient)
{
pSrcSFileClient->Release();
}
if( pDestSFileHdl)
{
pDestSFileHdl->Release();
}
if( pDestSFileClient)
{
pDestSFileClient->Release();
}
return( rc);
}