Skip to content

Commit

Permalink
Replacing void with template function
Browse files Browse the repository at this point in the history
  • Loading branch information
williamfgc committed Mar 7, 2019
1 parent 7381d9e commit 86794f6
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions thirdparty/KWSys/adios2sys/SystemTools.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -4666,22 +4666,28 @@ void SystemTools::ClassInitialize()
#endif
}

void SystemTools::ClassFinalize()
namespace {

template <class T>
void SafeDelete(T*& pointer)
{
auto lf_Delete = [](void** pointer) {
if (*pointer != nullptr) {
delete *pointer;
*pointer = nullptr;
}
};
if (pointer != nullptr) {
delete pointer;
pointer = nullptr;
}
}

} // end empty namespace

lf_Delete(SystemTools::TranslationMap);
void SystemTools::ClassFinalize()
{
SafeDelete(SystemTools::TranslationMap);
#ifdef _WIN32
lf_Delete(SystemTools::PathCaseMap);
lf_Delete(SystemTools::EnvMap);
SafeDelete(SystemTools::PathCaseMap);
SafeDelete(SystemTools::EnvMap);
#endif
#ifdef __CYGWIN__
lf_Delete(SystemTools::Cyg2Win32Map);
SafeDelete(SystemTools::Cyg2Win32Map);
#endif
}

Expand Down

0 comments on commit 86794f6

Please sign in to comment.