diff --git a/xflaim/src/fdbcopy.cpp b/xflaim/src/fdbcopy.cpp index d8a91fc..79d00dd 100644 --- a/xflaim/src/fdbcopy.cpp +++ b/xflaim/src/fdbcopy.cpp @@ -151,10 +151,10 @@ RCODE F_DbSystem::copyDb( { RCODE rc = NE_XFLM_OK; DB_COPY_INFO DbCopyInfo; - F_SuperFileHdl SrcSFileHdl; - F_SuperFileHdl DestSFileHdl; - F_SuperFileClient SrcSFileClient; - F_SuperFileClient DestSFileClient; + F_SuperFileHdl * pSrcSFileHdl = NULL; + F_SuperFileHdl * pDestSFileHdl = NULL; + F_SuperFileClient * pSrcSFileClient = NULL; + F_SuperFileClient * pDestSFileClient = NULL; FLMUINT uiFileNumber; FLMUINT uiHighFileNumber; FLMUINT uiHighLogFileNumber; @@ -210,13 +210,25 @@ RCODE F_DbSystem::copyDb( // 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( NE_XFLM_MEM); + goto Exit; + } - if( RC_BAD( rc = SrcSFileClient.setup( pszSrcDbName, pszSrcDataDir))) + if( RC_BAD( rc = pSrcSFileClient->setup( pszSrcDbName, pszSrcDataDir))) { goto Exit; } - if (RC_BAD( rc = SrcSFileHdl.setup( &SrcSFileClient))) + if( (pSrcSFileHdl = f_new F_SuperFileHdl) == NULL) + { + rc = RC_SET( NE_XFLM_MEM); + goto Exit; + } + + if (RC_BAD( rc = pSrcSFileHdl->setup( pSrcSFileClient))) { goto Exit; } @@ -322,13 +334,25 @@ retry: } // Set up the super file object for the destination database. + + if( (pDestSFileClient = f_new F_SuperFileClient) == NULL) + { + rc = RC_SET( NE_XFLM_MEM); + goto Exit; + } - if( RC_BAD( rc = DestSFileClient.setup( pszDestDbName, pszDestDataDir))) + if( RC_BAD( rc = pDestSFileClient->setup( pszDestDbName, pszDestDataDir))) { goto Exit; } - if (RC_BAD( rc = DestSFileHdl.setup( &DestSFileClient))) + if( (pDestSFileHdl = f_new F_SuperFileHdl) == NULL) + { + rc = RC_SET( NE_XFLM_MEM); + goto Exit; + } + + if (RC_BAD( rc = pDestSFileHdl->setup( pDestSFileClient))) { goto Exit; } @@ -338,7 +362,7 @@ retry: uiHighFileNumber = 0; for (;;) { - if ((RC_BAD( rc = SrcSFileHdl.getFileSize( + if ((RC_BAD( rc = pSrcSFileHdl->getFileSize( uiHighFileNumber, &ui64FileSize))) || !ui64FileSize ) { if (rc == NE_FLM_IO_PATH_NOT_FOUND || @@ -373,7 +397,7 @@ retry: uiHighLogFileNumber = FIRST_LOG_BLOCK_FILE_NUMBER; for (;;) { - if ((RC_BAD( rc = SrcSFileHdl.getFileSize( + if ((RC_BAD( rc = pSrcSFileHdl->getFileSize( uiHighLogFileNumber, &ui64FileSize))) || !ui64FileSize) { if (rc == NE_FLM_IO_PATH_NOT_FOUND || @@ -445,8 +469,8 @@ retry: // 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. @@ -455,12 +479,12 @@ retry: // 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; @@ -482,13 +506,13 @@ retry: // 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; @@ -700,6 +724,26 @@ Exit: f_semDestroy( &hWaitSem); } + if( pSrcSFileClient) + { + pSrcSFileClient->Release(); + } + + if( pSrcSFileHdl) + { + pSrcSFileHdl->Release(); + } + + if( pDestSFileClient) + { + pDestSFileClient->Release(); + } + + if( pDestSFileHdl) + { + pDestSFileHdl->Release(); + } + return( rc); } diff --git a/xflaim/util/view.cpp b/xflaim/util/view.cpp index 359bac7..a35ffbb 100644 --- a/xflaim/util/view.cpp +++ b/xflaim/util/view.cpp @@ -533,8 +533,9 @@ Desc: This routine opens the database file which is to be viewed. *****************************************************************************/ FSTATIC FLMBOOL ViewOpenFile( void) { - RCODE rc; - FLMBOOL bOk = FALSE; + RCODE rc; + FLMBOOL bOk = FALSE; + F_SuperFileClient * pSFileClient = NULL; Get_File_Name: @@ -555,19 +556,33 @@ Get_File_Name: goto Exit; } } + if (gv_pSFileHdl) { gv_pSFileHdl->Release(); gv_pSFileHdl = NULL; } + if ((pSFileClient = f_new F_SuperFileClient) == NULL) + { + rc = RC_SET( NE_XFLM_MEM); + goto Exit; + } + + if (RC_BAD( rc = pSFileClient->setup( gv_szViewFileName, gv_szDataDir))) + { + ViewShowRCError( "setting up super file handle", rc); + goto Exit; + } + if ((gv_pSFileHdl = f_new F_SuperFileHdl) == NULL) { rc = RC_SET( NE_XFLM_MEM); ViewShowRCError( "creating super file handle", rc); goto Exit; } - if (RC_BAD( rc = gv_pSFileHdl->setup( gv_szViewFileName, gv_szDataDir))) + + if (RC_BAD( rc = gv_pSFileHdl->setup( pSFileClient))) { ViewShowRCError( "setting up super file handle", rc); goto Exit; @@ -653,6 +668,12 @@ Exit: } gv_bViewFileOpened = FALSE; } + + if( pSFileClient) + { + pSFileClient->Release(); + } + return( bOk); }