summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2015-08-13 10:49:31 +0200
committerJulian Andres Klode <jak@debian.org>2015-08-13 11:30:59 +0200
commit6c413b188618b9fcb5368b60971dfa5d45b3cd74 (patch)
treeb50631d5318f7846368b9cc32f02568bdf86d895
parent47c37a1bfc2f2f372bf057bf68bde0b3b6f0ec8f (diff)
Mark SPtr as deprecated, and convert users to std::unique_ptr
Switch to std::unique_ptr, as this is safer than SPtr.
-rw-r--r--apt-pkg/contrib/sptr.h2
-rw-r--r--apt-pkg/pkgcachegen.cc28
-rw-r--r--apt-private/private-install.cc10
-rw-r--r--cmdline/apt-get.cc6
4 files changed, 23 insertions, 23 deletions
diff --git a/apt-pkg/contrib/sptr.h b/apt-pkg/contrib/sptr.h
index e2e811b1d..5cf118b84 100644
--- a/apt-pkg/contrib/sptr.h
+++ b/apt-pkg/contrib/sptr.h
@@ -22,7 +22,7 @@
#define SMART_POINTER_H
template <class T>
-class SPtr
+class APT_DEPRECATED SPtr
{
public:
T *Ptr;
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc
index ef7afda94..a9de20878 100644
--- a/apt-pkg/pkgcachegen.cc
+++ b/apt-pkg/pkgcachegen.cc
@@ -1250,8 +1250,8 @@ static bool CheckValidity(const string &CacheFile,
// Map it
FileFd CacheF(CacheFile,FileFd::ReadOnly);
- SPtr<MMap> Map = new MMap(CacheF,0);
- pkgCache Cache(Map);
+ std::unique_ptr<MMap> Map(new MMap(CacheF,0));
+ pkgCache Cache(Map.get());
if (_error->PendingError() == true || Map->Size() == 0)
{
if (Debug == true)
@@ -1342,7 +1342,7 @@ static bool CheckValidity(const string &CacheFile,
}
if (OutMap != 0)
- *OutMap = Map.UnGuard();
+ *OutMap = Map.release();
return true;
}
/*}}}*/
@@ -1483,16 +1483,16 @@ static bool writeBackMMapToFile(pkgCacheGenerator * const Gen, DynamicMMap * con
return true;
}
static bool loadBackMMapFromFile(std::unique_ptr<pkgCacheGenerator> &Gen,
- SPtr<DynamicMMap> &Map, OpProgress * const Progress, std::string const &FileName)
+ std::unique_ptr<DynamicMMap> &Map, OpProgress * const Progress, std::string const &FileName)
{
- Map = CreateDynamicMMap(NULL, 0);
+ Map.reset(CreateDynamicMMap(NULL, 0));
FileFd CacheF(FileName, FileFd::ReadOnly);
map_pointer_t const alloc = Map->RawAllocate(CacheF.Size());
if ((alloc == 0 && _error->PendingError())
|| CacheF.Read((unsigned char *)Map->Data() + alloc,
CacheF.Size()) == false)
return false;
- Gen.reset(new pkgCacheGenerator(Map.Get(),Progress));
+ Gen.reset(new pkgCacheGenerator(Map.get(),Progress));
return true;
}
APT_DEPRECATED bool pkgMakeStatusCache(pkgSourceList &List,OpProgress &Progress,
@@ -1578,7 +1578,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
}
// At this point we know we need to construct something, so get storage ready
- SPtr<DynamicMMap> Map = CreateDynamicMMap(NULL, 0);
+ std::unique_ptr<DynamicMMap> Map(CreateDynamicMMap(NULL, 0));
if (Debug == true)
std::clog << "Open memory Map (not filebased)" << std::endl;
@@ -1599,7 +1599,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
{
if (Debug == true)
std::clog << "srcpkgcache.bin is NOT valid - rebuild" << std::endl;
- Gen.reset(new pkgCacheGenerator(Map.Get(),Progress));
+ Gen.reset(new pkgCacheGenerator(Map.get(),Progress));
TotalSize += ComputeSize(&List, Files.begin(),Files.end());
if (BuildCache(*Gen, Progress, CurrentSize, TotalSize, &List,
@@ -1607,7 +1607,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
return false;
if (Writeable == true && SrcCacheFile.empty() == false)
- if (writeBackMMapToFile(Gen.get(), Map.Get(), SrcCacheFile) == false)
+ if (writeBackMMapToFile(Gen.get(), Map.get(), SrcCacheFile) == false)
return false;
}
@@ -1620,7 +1620,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
return false;
if (Writeable == true && CacheFile.empty() == false)
- if (writeBackMMapToFile(Gen.get(), Map.Get(), CacheFile) == false)
+ if (writeBackMMapToFile(Gen.get(), Map.get(), CacheFile) == false)
return false;
}
@@ -1644,7 +1644,7 @@ bool pkgCacheGenerator::MakeStatusCache(pkgSourceList &List,OpProgress *Progress
}
if (OutMap != nullptr)
- *OutMap = Map.UnGuard();
+ *OutMap = Map.release();
if (Debug == true)
std::clog << "Everything is ready for shipping" << std::endl;
@@ -1662,7 +1662,7 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O
if (_system->AddStatusFiles(Files) == false)
return false;
- SPtr<DynamicMMap> Map = CreateDynamicMMap(NULL, 0);
+ std::unique_ptr<DynamicMMap> Map(CreateDynamicMMap(NULL, 0));
map_filesize_t CurrentSize = 0;
map_filesize_t TotalSize = 0;
@@ -1671,7 +1671,7 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O
// Build the status cache
if (Progress != NULL)
Progress->OverallProgress(0,1,1,_("Reading package lists"));
- pkgCacheGenerator Gen(Map.Get(),Progress);
+ pkgCacheGenerator Gen(Map.get(),Progress);
if (_error->PendingError() == true)
return false;
if (BuildCache(Gen,Progress,CurrentSize,TotalSize, NULL,
@@ -1680,7 +1680,7 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O
if (_error->PendingError() == true)
return false;
- *OutMap = Map.UnGuard();
+ *OutMap = Map.release();
return true;
}
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 074874903..d2b4bed51 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -128,7 +128,7 @@ bool InstallPackages(CacheFile &Cache,bool ShwKept,bool Ask, bool Safety)
pkgSourceList *List = Cache.GetSourceList();
// Create the package manager and prepare to download
- SPtr<pkgPackageManager> PM= _system->CreatePM(Cache);
+ std::unique_ptr<pkgPackageManager> PM(_system->CreatePM(Cache));
if (PM->GetArchives(&Fetcher,List,&Recs) == false ||
_error->PendingError() == true)
return false;
@@ -492,9 +492,9 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
if (Cache->BrokenCount() != 0)
BrokenFix = true;
- SPtr<pkgProblemResolver> Fix;
+ std::unique_ptr<pkgProblemResolver> Fix(nullptr);
if (_config->FindB("APT::Get::CallResolver", true) == true)
- Fix = new pkgProblemResolver(Cache);
+ Fix.reset(new pkgProblemResolver(Cache));
unsigned short fallback = MOD_INSTALL;
if (strcasecmp(CmdL.FileList[0],"remove") == 0)
@@ -526,8 +526,8 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, CacheFile &Cache,
}
- TryToInstall InstallAction(Cache, Fix, BrokenFix);
- TryToRemove RemoveAction(Cache, Fix);
+ TryToInstall InstallAction(Cache, Fix.get(), BrokenFix);
+ TryToRemove RemoveAction(Cache, Fix.get());
// new scope for the ActionGroup
{
diff --git a/cmdline/apt-get.cc b/cmdline/apt-get.cc
index b0e646833..0b79c507a 100644
--- a/cmdline/apt-get.cc
+++ b/cmdline/apt-get.cc
@@ -1000,7 +1000,7 @@ static bool DoBuildDep(CommandLine &CmdL)
{
string Src;
pkgSrcRecords::Parser *Last = 0;
- SPtr<pkgSrcRecords::Parser> LastOwner;
+ std::unique_ptr<pkgSrcRecords::Parser> LastOwner;
// an unpacked debian source tree
using APT::String::Startswith;
@@ -1012,7 +1012,7 @@ static bool DoBuildDep(CommandLine &CmdL)
std::string TypeName = "Debian control file";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
- LastOwner = Last = Type->CreateSrcPkgParser(*I);
+ LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
}
// if its a local file (e.g. .dsc) use this
else if (FileExists(*I))
@@ -1023,7 +1023,7 @@ static bool DoBuildDep(CommandLine &CmdL)
string TypeName = "Debian " + flExtension(*I) + " file";
pkgIndexFile::Type *Type = pkgIndexFile::Type::GetType(TypeName.c_str());
if(Type != NULL)
- LastOwner = Last = Type->CreateSrcPkgParser(*I);
+ LastOwner.reset(Last = Type->CreateSrcPkgParser(*I));
} else {
// normal case, search the cache for the source file
Last = FindSrc(*I,SrcRecs,Src,Cache);