diff --git a/GeoLib/IO/Legacy/OGSIOVer4.cpp b/GeoLib/IO/Legacy/OGSIOVer4.cpp index 8ee236a70762392a50a95d934e5d2b5e784adbb6..8503ced9c15e6df2d0d7226b533ce08bf6355e0a 100644 --- a/GeoLib/IO/Legacy/OGSIOVer4.cpp +++ b/GeoLib/IO/Legacy/OGSIOVer4.cpp @@ -456,23 +456,27 @@ bool readGLIFileV4(const std::string& fname, getline (in, tag); // read names of points into vector of strings - auto* pnt_id_names_map(new std::map<std::string, std::size_t>); + auto pnt_id_names_map = + std::unique_ptr<std::map<std::string, std::size_t>>{}; + bool zero_based_idx(true); auto pnt_vec = std::unique_ptr<std::vector<GeoLib::Point*>>( new std::vector<GeoLib::Point*>); INFO("GeoLib::readGLIFile(): read points from stream."); - tag = readPoints(in, pnt_vec.get(), zero_based_idx, pnt_id_names_map); + tag = readPoints(in, pnt_vec.get(), zero_based_idx, pnt_id_names_map.get()); INFO("GeoLib::readGLIFile(): \t ok, %d points read.", pnt_vec->size()); unique_name = BaseLib::extractBaseName(fname); if (!pnt_vec->empty()) - geo.addPointVec(std::move(pnt_vec), unique_name, pnt_id_names_map, 1e-6); + geo.addPointVec(std::move(pnt_vec), unique_name, + std::move(pnt_id_names_map), 1e-6); // extract path for reading external files const std::string path = BaseLib::extractPath(fname); // read names of plys into temporary string-vec - auto* ply_names(new std::map<std::string, std::size_t>); + auto ply_names = std::unique_ptr<std::map<std::string, std::size_t>>{ + new std::map<std::string, std::size_t>}; auto ply_vec = std::unique_ptr<std::vector<GeoLib::Polyline*>>( new std::vector<GeoLib::Polyline*>); GeoLib::PointVec & point_vec( @@ -492,7 +496,8 @@ bool readGLIFileV4(const std::string& fname, auto sfc_vec = std::unique_ptr<std::vector<GeoLib::Surface*>>( new std::vector<GeoLib::Surface*>); - auto* sfc_names(new std::map<std::string, std::size_t>); + auto sfc_names = std::unique_ptr<std::map<std::string, std::size_t>>{ + new std::map<std::string, std::size_t>}; if (tag.find("#SURFACE") != std::string::npos && in) { INFO("GeoLib::readGLIFile(): read surfaces from stream."); @@ -512,16 +517,14 @@ bool readGLIFileV4(const std::string& fname, in.close(); if (!ply_vec->empty()) - geo.addPolylineVec(std::move(ply_vec), unique_name, ply_names); // KR: insert into GEOObjects if not empty - else { - delete ply_names; - } + geo.addPolylineVec( + std::move(ply_vec), unique_name, + std::move(ply_names)); // KR: insert into GEOObjects if not empty if (!sfc_vec->empty()) - geo.addSurfaceVec(std::move(sfc_vec), unique_name, sfc_names); // KR: insert into GEOObjects if not empty - else { - delete sfc_names; - } + geo.addSurfaceVec( + std::move(sfc_vec), unique_name, + std::move(sfc_names)); // KR: insert into GEOObjects if not empty if (errors.empty()) return true;