mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-04-10 16:07:28 +05:00
Suppress memory leak when using Kernel_Utils::decode()
+ some code cleanup
This commit is contained in:
parent
f016bdf914
commit
6b5dcfe000
@ -41,9 +41,6 @@ class LightApp_SelectionMgr;
|
||||
/*!
|
||||
* The GeomSelectionTools class gives high level tools to select Geom (and other objects)
|
||||
* A specific attention has been given to analyze selected GEOM objects.
|
||||
*
|
||||
* @param myStudy This class is specific to the study !
|
||||
*
|
||||
*/
|
||||
|
||||
class PLUGINUTILS_EXPORT GeomSelectionTools
|
||||
|
@ -52,7 +52,8 @@ static std::string removeFile(std::string fileName, int& notOk)
|
||||
|
||||
return errStr;
|
||||
}
|
||||
std::string MG_ADAPT::remove_extension(const std::string& filename) {
|
||||
std::string MG_ADAPT::remove_extension(const std::string& filename)
|
||||
{
|
||||
size_t lastdot = filename.find_last_of(".");
|
||||
if (lastdot == std::string::npos) return filename;
|
||||
return filename.substr(0, lastdot);
|
||||
@ -78,7 +79,6 @@ med_idt openMedFile(const std::string aFile)
|
||||
return medIdt;
|
||||
}
|
||||
|
||||
|
||||
// =======================================================================
|
||||
void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit, std::string fieldName)
|
||||
// =======================================================================
|
||||
@ -88,7 +88,6 @@ void getTimeStepInfos(std::string aFile, med_int& numdt, med_int& numit, std::st
|
||||
herr_t erreur = 0 ;
|
||||
med_idt medIdt ;
|
||||
|
||||
|
||||
// Ouverture du fichier
|
||||
//~SCRUTE(aFile.toStdString());
|
||||
medIdt = openMedFile(aFile);
|
||||
@ -162,7 +161,8 @@ class outFileStream : public std::ofstream{
|
||||
public:
|
||||
~outFileStream(){close();} //to close file at dtor
|
||||
};
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
//----------------------------------------------------------------------------------------
|
||||
MgAdapt::MgAdapt()
|
||||
@ -867,6 +867,7 @@ void MgAdapt::execCmd( const char* cmd, int& err)
|
||||
#if defined(WIN32)
|
||||
# if defined(UNICODE)
|
||||
const wchar_t * aCmd = Kernel_Utils::utf8_decode(cmd);
|
||||
SMESHUtils::ArrayDeleter<const wchar_t> deleter( aCmd );
|
||||
std::unique_ptr <FILE, decltype(&_pclose)> pipe(_wpopen(aCmd, O_RDONLY), _pclose );
|
||||
# else
|
||||
std::unique_ptr <FILE, decltype(&_pclose)> pipe(_popen(cmd, "r"), _pclose );
|
||||
|
@ -1079,16 +1079,12 @@ std::vector< std::string > SMESH_Gen::GetPluginXMLPaths()
|
||||
#ifdef WIN32
|
||||
# ifdef UNICODE
|
||||
const wchar_t* path = Kernel_Utils::decode_s(xmlPath);
|
||||
SMESHUtils::ArrayDeleter<const wchar_t> deleter( path );
|
||||
# else
|
||||
const char* path = xmlPath.c_str();
|
||||
# endif
|
||||
|
||||
fileOK = (GetFileAttributes(path) != INVALID_FILE_ATTRIBUTES);
|
||||
|
||||
#ifdef UNICODE
|
||||
delete path;
|
||||
#endif
|
||||
|
||||
#else
|
||||
fileOK = (access(xmlPath.c_str(), F_OK) == 0);
|
||||
#endif
|
||||
|
@ -104,6 +104,8 @@ namespace SMESHUtils
|
||||
TOBJ* _obj;
|
||||
ArrayDeleter( TOBJ* obj ): _obj( obj ) {}
|
||||
~ArrayDeleter() { delete [] _obj; _obj = 0; }
|
||||
operator TOBJ*() { return _obj; }
|
||||
TOBJ* get() { return _obj; }
|
||||
private:
|
||||
ArrayDeleter( const ArrayDeleter& );
|
||||
};
|
||||
|
@ -462,6 +462,7 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp
|
||||
#ifdef WIN32
|
||||
# ifdef UNICODE
|
||||
const wchar_t* path = Kernel_Utils::decode_s(aPlatformLibName);
|
||||
SMESHUtils::ArrayDeleter<const wchar_t> deleter( path );
|
||||
# else
|
||||
const char* path = aPlatformLibName.c_str();
|
||||
# endif
|
||||
@ -469,9 +470,7 @@ GenericHypothesisCreator_i* SMESH_Gen_i::getHypothesisCreator(const char* theHyp
|
||||
const char* path = aPlatformLibName.c_str();
|
||||
#endif
|
||||
LibHandle libHandle = LoadLib( path );
|
||||
#if defined(WIN32) && defined(UNICODE)
|
||||
delete path;
|
||||
#endif
|
||||
|
||||
if (!libHandle)
|
||||
{
|
||||
// report any error, if occurred
|
||||
@ -5194,7 +5193,8 @@ bool SMESH_Gen_i::Load( SALOMEDS::SComponent_ptr theComponent,
|
||||
TCollection_AsciiString aStudyName( "" );
|
||||
if ( isMultiFile ) {
|
||||
CORBA::WString_var url = aStudy->URL();
|
||||
aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( Kernel_Utils::encode(url.in()) ).c_str();
|
||||
SMESHUtils::ArrayDeleter<const char> urlMulibyte( Kernel_Utils::encode( url.in()) );
|
||||
aStudyName = (char*)SALOMEDS_Tool::GetNameFromPath( urlMulibyte.get() ).c_str();
|
||||
}
|
||||
// Set names of temporary files
|
||||
TCollection_AsciiString filename = tmpDir + aStudyName + "_SMESH.hdf";
|
||||
|
Loading…
x
Reference in New Issue
Block a user