]> git.saurik.com Git - apt.git/blobdiff - apt-pkg/pkgcachegen.cc
apt-pkg/contrib/srvrec.cc: res_query() should not generate a _error->Warning()
[apt.git] / apt-pkg / pkgcachegen.cc
index ef7afda944d177f21ab56a322e2a19c0d5bf0c8e..6daebbc2aff75c7a5a8c910150ce73b581123058 100644 (file)
@@ -18,8 +18,6 @@
 #include <apt-pkg/progress.h>
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/configuration.h>
-#include <apt-pkg/strutl.h>
-#include <apt-pkg/sptr.h>
 #include <apt-pkg/pkgsystem.h>
 #include <apt-pkg/macros.h>
 #include <apt-pkg/metaindex.h>
@@ -1250,8 +1248,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 +1258,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 +1293,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 +1340,7 @@ static bool CheckValidity(const string &CacheFile,
    }
    
    if (OutMap != 0)
-      *OutMap = Map.UnGuard();
+      *OutMap = Map.release();
    return true;
 }
                                                                        /*}}}*/
@@ -1483,16 +1481,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 +1576,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 +1597,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 +1605,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 +1618,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 +1642,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 +1660,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 +1669,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 +1678,7 @@ bool pkgCacheGenerator::MakeOnlyStatusCache(OpProgress *Progress,DynamicMMap **O
 
    if (_error->PendingError() == true)
       return false;
-   *OutMap = Map.UnGuard();
+   *OutMap = Map.release();
    
    return true;
 }