diff options
Diffstat (limited to 'apt-pkg/pkgcachegen.cc')
-rw-r--r-- | apt-pkg/pkgcachegen.cc | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/apt-pkg/pkgcachegen.cc b/apt-pkg/pkgcachegen.cc index ef7afda94..68175a24a 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) @@ -1260,8 +1260,8 @@ static bool CheckValidity(const string &CacheFile, return false; } - SPtrArray<bool> RlsVisited = new bool[Cache.HeaderP->ReleaseFileCount]; - memset(RlsVisited,0,sizeof(*RlsVisited)*Cache.HeaderP->ReleaseFileCount); + std::unique_ptr<bool[]> RlsVisited(new bool[Cache.HeaderP->ReleaseFileCount]); + memset(RlsVisited.get(),0,sizeof(RlsVisited[0])*Cache.HeaderP->ReleaseFileCount); std::vector<pkgIndexFile *> Files; for (pkgSourceList::const_iterator i = List.begin(); i != List.end(); ++i) { @@ -1295,8 +1295,8 @@ static bool CheckValidity(const string &CacheFile, /* Now we check every index file, see if it is in the cache, verify the IMS data and check that it is on the disk too.. */ - SPtrArray<bool> Visited = new bool[Cache.HeaderP->PackageFileCount]; - memset(Visited,0,sizeof(*Visited)*Cache.HeaderP->PackageFileCount); + std::unique_ptr<bool[]> Visited(new bool[Cache.HeaderP->PackageFileCount]); + memset(Visited.get(),0,sizeof(Visited[0])*Cache.HeaderP->PackageFileCount); for (std::vector<pkgIndexFile *>::const_reverse_iterator PkgFile = Files.rbegin(); PkgFile != Files.rend(); ++PkgFile) { 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; } |