summaryrefslogtreecommitdiffstats
path: root/Source/cmCPluginAPI.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmCPluginAPI.cxx')
-rw-r--r--Source/cmCPluginAPI.cxx34
1 files changed, 9 insertions, 25 deletions
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index b5c7e96..f6c1e47 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -488,24 +488,8 @@ struct cmCPluginAPISourceFile
// Keep a map from real cmSourceFile instances stored in a makefile to
// the CPluginAPI proxy source file.
-class cmCPluginAPISourceFileMap
- : public std::map<cmSourceFile*, cmCPluginAPISourceFile*>
-{
-public:
- using derived = std::map<cmSourceFile*, cmCPluginAPISourceFile*>;
- using iterator = derived::iterator;
- using value_type = derived::value_type;
- cmCPluginAPISourceFileMap() = default;
- ~cmCPluginAPISourceFileMap()
- {
- for (auto const& i : *this) {
- delete i.second;
- }
- }
- cmCPluginAPISourceFileMap(const cmCPluginAPISourceFileMap&) = delete;
- cmCPluginAPISourceFileMap& operator=(const cmCPluginAPISourceFileMap&) =
- delete;
-};
+using cmCPluginAPISourceFileMap =
+ std::map<cmSourceFile*, std::unique_ptr<cmCPluginAPISourceFile>>;
cmCPluginAPISourceFileMap cmCPluginAPISourceFiles;
void* CCONV cmCreateSourceFile(void)
@@ -536,7 +520,7 @@ void CCONV* cmGetSource(void* arg, const char* name)
auto i = cmCPluginAPISourceFiles.find(rsf);
if (i == cmCPluginAPISourceFiles.end()) {
// Create a proxy source file object for this source.
- cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
+ auto sf = cm::make_unique<cmCPluginAPISourceFile>();
sf->RealSourceFile = rsf;
sf->FullPath = rsf->ResolveFullPath();
sf->SourceName =
@@ -545,10 +529,9 @@ void CCONV* cmGetSource(void* arg, const char* name)
cmSystemTools::GetFilenameLastExtension(sf->FullPath);
// Store the proxy in the map so it can be re-used and deleted later.
- cmCPluginAPISourceFileMap::value_type entry(rsf, sf);
- i = cmCPluginAPISourceFiles.insert(entry).first;
+ i = cmCPluginAPISourceFiles.emplace(rsf, std::move(sf)).first;
}
- return i->second;
+ return i->second.get();
}
return nullptr;
}
@@ -569,15 +552,16 @@ void* CCONV cmAddSource(void* arg, void* arg2)
}
// Create the proxy for the real source file.
- cmCPluginAPISourceFile* sf = new cmCPluginAPISourceFile;
+ auto sf = cm::make_unique<cmCPluginAPISourceFile>();
sf->RealSourceFile = rsf;
sf->FullPath = osf->FullPath;
sf->SourceName = osf->SourceName;
sf->SourceExtension = osf->SourceExtension;
// Store the proxy in the map so it can be re-used and deleted later.
- cmCPluginAPISourceFiles[rsf] = sf;
- return sf;
+ auto value = sf.get();
+ cmCPluginAPISourceFiles[rsf] = std::move(sf);
+ return value;
}
const char* CCONV cmSourceFileGetSourceName(void* arg)