From 5bfcb5e09b3c8608abb8e0e573d3d20965d25755 Mon Sep 17 00:00:00 2001 From: sln Date: Tue, 10 Apr 2012 09:19:55 +0000 Subject: [PATCH] size_t replaced witf t_size (unsigned int) to adopt persistence of 32 and 64 bit platforms --- src/LightApp/LightApp_Driver.cxx | 26 +++++++++++++------------- src/LightApp/LightApp_Driver.h | 18 ++++++++++-------- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/LightApp/LightApp_Driver.cxx b/src/LightApp/LightApp_Driver.cxx index eb42e2d33..15bf14521 100644 --- a/src/LightApp/LightApp_Driver.cxx +++ b/src/LightApp/LightApp_Driver.cxx @@ -509,8 +509,8 @@ bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, u TCollection_AsciiString aTmpDir(const_cast(aFiles[0].c_str())); int aNbFiles = 0; - myFileNameSizes = new size_t[aLength]; - myFileSizes = new size_t[aLength]; + myFileNameSizes = new t_size[aLength]; + myFileSizes = new t_size[aLength]; //Determine the required size of the buffer TCollection_AsciiString aFileName; @@ -544,7 +544,7 @@ bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, u mySizeToBeWritten += 4; //4 bytes for a number of the files that will be written to the stream; - size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); + t_size aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); theBuffer = new unsigned char[ aCurrSize ]; myCurrBuff = theBuffer; @@ -609,7 +609,7 @@ bool LightApp_Driver::PutFilesToFirstStream( const std::string& theModuleName, u { myCurrIFile->seekg(0, ios::beg); int aPos = myCurrIFile->tellg(); - size_t aSizeToRead = GetMaxBuffSize() - myCurrPos; + t_size aSizeToRead = GetMaxBuffSize() - myCurrPos; if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() ) aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead ); @@ -666,7 +666,7 @@ bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, un TCollection_AsciiString aTmpDir(const_cast(aFiles[0].c_str())); - size_t aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); + t_size aCurrSize = mySizeToBeWritten <= GetMaxBuffSize() ? mySizeToBeWritten : GetMaxBuffSize(); for ( ; myCurrFileIndex < aLength; myCurrFileIndex++ ) { @@ -713,7 +713,7 @@ bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, un if ( aCurrSize < GetMaxBuffSize() ) { //myCurrIFile->seekg(0, ios::beg); - size_t aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); + t_size aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead ); myCurrIFile->close(); delete(myCurrIFile); @@ -724,8 +724,8 @@ bool LightApp_Driver::PutFilesToNextStream( const std::string& theModuleName, un else // new code for big files { int aPos = myCurrIFile->tellg(); - size_t aFileSize = myFileSizes[myCurrFileIndex]; - size_t aSizeToRead = GetMaxBuffSize() - myCurrPos; + t_size aFileSize = myFileSizes[myCurrFileIndex]; + t_size aSizeToRead = GetMaxBuffSize() - myCurrPos; if ( aSizeToRead > myFileSizes[myCurrFileIndex] - myCurrIFile->tellg() ) aSizeToRead = myFileSizes[myCurrFileIndex] - myCurrIFile->tellg(); myCurrIFile->read((char *)(theBuffer + myCurrPos), aSizeToRead ); @@ -792,8 +792,8 @@ void LightApp_Driver::PutFirstStreamToFiles( ListOfFiles& theListOfFiles, const int n = myNbFilles + 1; theListOfFiles.resize( n ); - myFileSizes = new size_t[ n ]; - myFileNameSizes = new size_t[ n ]; + myFileSizes = new t_size[ n ]; + myFileNameSizes = new t_size[ n ]; theListOfFiles[ 0 ] = aDir; myFileSizes[ 0 ] = 0; myFileNameSizes[ 0 ] = 0; @@ -840,7 +840,7 @@ void LightApp_Driver::PutFirstStreamToFiles( ListOfFiles& theListOfFiles, else { // old code for big files - size_t aSize = theBufferSize - myCurrPos; + t_size aSize = theBufferSize - myCurrPos; myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize ); myFileSizes[ myCurrFileIndex ] -= aSize; myCurrPos = 0; @@ -922,8 +922,8 @@ void LightApp_Driver::PutNextStreamToFiles( ListOfFiles& theListOfFiles, else { // old code for big files - size_t aFileSize = myFileSizes[ myCurrFileIndex ]; - size_t aSize = theBufferSize - myCurrPos; + t_size aFileSize = myFileSizes[ myCurrFileIndex ]; + t_size aSize = theBufferSize - myCurrPos; myCurrOFile->write((char *)( theBuffer + myCurrPos ), aSize ); myFileSizes[ myCurrFileIndex ] -= aSize; myCurrPos = 0; diff --git a/src/LightApp/LightApp_Driver.h b/src/LightApp/LightApp_Driver.h index 25d4842be..1ef96c4e8 100644 --- a/src/LightApp/LightApp_Driver.h +++ b/src/LightApp/LightApp_Driver.h @@ -31,6 +31,8 @@ #pragma warning( disable:4251 ) #endif +typedef unsigned int t_size; + class QString; /*!Description : Driver can save to file and read from file list of files for light modules*/ @@ -76,7 +78,7 @@ protected: void PutNextStreamToFiles( ListOfFiles& theListOfFiles, const unsigned char* theBuffer, const long theBufferSize, bool theNamesOnly = false); - inline static size_t GetMaxBuffSize(); + inline static t_size GetMaxBuffSize(); std::string GetTmpDir(); std::string GetDirFromPath(const std::string& thePath); @@ -103,26 +105,26 @@ private: int myCurrFileIndex; // writing - size_t myCurrPos; + t_size myCurrPos; unsigned char* myCurrBuff; ifstream* myCurrIFile; - size_t mySizeToBeWritten; - size_t* myFileSizes; - size_t* myFileNameSizes; + t_size mySizeToBeWritten; + t_size* myFileSizes; + t_size* myFileNameSizes; // reading ofstream* myCurrOFile; long myNbFilles; }; -inline size_t LightApp_Driver::GetMaxBuffSize() +inline t_size LightApp_Driver::GetMaxBuffSize() { - static size_t aValue = 0; + static t_size aValue = 0; if ( !aValue ) { char* aVar = getenv( "HDF_BUFFER_SIZE" ); if ( aVar ) - aValue = (size_t)atol( aVar ); + aValue = (t_size)atol( aVar ); else aValue = 50000000; } -- 2.39.2