Skip to content
Snippets Groups Projects
Commit 12b87085 authored by Tom Fischer's avatar Tom Fischer
Browse files

Merge pull request #1054 from TomFischer/FixClangSanitizerIssues

Fix clang sanitizer issues
parents 7104bbaf 48bd905f
No related branches found
No related tags found
No related merge requests found
......@@ -56,13 +56,16 @@ void truncateFile( std::string const& filename)
ofs.close();
}
namespace
{
/** Finds the position of last file path separator.
* Checks for unix or windows file path separators in given path and returns the
* position of the last one or std::string::npos if no file path separator was
* found.
*/
static
std::size_t findLastPathSeparator(std::string const& path)
std::string::size_type findLastPathSeparator(std::string const& path)
{
return path.find_last_of("/\\");
}
......@@ -71,20 +74,21 @@ std::size_t findLastPathSeparator(std::string const& path)
* This could be used to extract file extension.
*/
static
std::size_t findLastDot(std::string const& path)
std::string::size_type findLastDot(std::string const& path)
{
return path.find_last_of(".");
}
} // end namespace
std::string dropFileExtension(std::string const& filename)
{
// Look for dots in filename.
const std::size_t p = findLastDot(filename);
auto const p = findLastDot(filename);
if (p == std::string::npos)
return filename;
// Check position of the last path separator.
const std::size_t s = findLastPathSeparator(filename);
auto const s = findLastPathSeparator(filename);
if (s != std::string::npos && p < s)
return filename;
......@@ -93,7 +97,7 @@ std::string dropFileExtension(std::string const& filename)
std::string extractBaseName(std::string const& pathname)
{
const std::size_t p = findLastPathSeparator(pathname);
auto const p = findLastPathSeparator(pathname);
if (p == std::string::npos)
return pathname;
return pathname.substr(p + 1);
......@@ -108,7 +112,7 @@ std::string extractBaseNameWithoutExtension(std::string const& pathname)
std::string getFileExtension(const std::string &path)
{
const std::string str = extractBaseName(path);
const std::size_t p = findLastDot(str);
auto const p = findLastDot(str);
if (p == std::string::npos)
return std::string();
return str.substr(p + 1);
......@@ -123,7 +127,7 @@ std::string copyPathToFileName(const std::string &file_name,
const std::string &source)
{
// check if file_name already contains a full path
const std::size_t pos = findLastPathSeparator(file_name);
auto const pos = findLastPathSeparator(file_name);
if (pos != std::string::npos)
return file_name;
......@@ -132,7 +136,7 @@ std::string copyPathToFileName(const std::string &file_name,
std::string extractPath(std::string const& pathname)
{
const std::size_t pos = findLastPathSeparator(pathname);
auto const pos = findLastPathSeparator(pathname);
if (pos == std::string::npos)
return "";
return pathname.substr(0, pos + 1);
......
......@@ -31,6 +31,8 @@ BoundaryElementsSearcher::BoundaryElementsSearcher(MeshLib::Mesh const& mesh, Me
BoundaryElementsSearcher::~BoundaryElementsSearcher()
{
for (auto p : _boundary_elements_at_point)
delete p;
for (auto p : _boundary_elements_along_polylines)
delete p;
for (auto p : _boundary_elements_along_surfaces)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment