Kaynağa Gözat

stop using IndexTarget pointers which are never freed

Creating and passing around a bunch of pointers of IndexTargets (and of
a vector of pointers of IndexTargets) is probably done to avoid the
'costly' copy of container, but we are really not in a timecritical
operation here and move semantics will help us even further in the
future. On the other hand we never do a proper cleanup of these
pointers, which is very dirty, even if structures aren't that big…

The changes will effecting many items only effect our own hidden class,
so we can do that without fearing breaking interfaces or anything.

Git-Dch: Ignore
David Kalnischkies 11 yıl önce
ebeveyn
işleme
dcbbb14df8

+ 83 - 84
apt-pkg/acquire-item.cc

@@ -191,7 +191,7 @@ HashStringList pkgAcqIndexMergeDiffs::GetExpectedHashes() const
    if (State == StateFetchDiff)
    if (State == StateFetchDiff)
       return patch.download_hashes;
       return patch.download_hashes;
    else if (State == StateApplyDiff)
    else if (State == StateApplyDiff)
-      return GetExpectedHashesFor(Target->MetaKey);
+      return GetExpectedHashesFor(Target.MetaKey);
    return HashStringList();
    return HashStringList();
 }
 }
 
 
@@ -266,20 +266,20 @@ std::string pkgAcqDiffIndex::GetFinalFilename() const
 }
 }
 std::string pkgAcqIndex::GetFinalFilename() const
 std::string pkgAcqIndex::GetFinalFilename() const
 {
 {
-   std::string const FinalFile = GetFinalFileNameFromURI(Target->URI);
-   return GetCompressedFileName(Target->URI, FinalFile, CurrentCompressionExtension);
+   std::string const FinalFile = GetFinalFileNameFromURI(Target.URI);
+   return GetCompressedFileName(Target.URI, FinalFile, CurrentCompressionExtension);
 }
 }
 std::string pkgAcqMetaSig::GetFinalFilename() const
 std::string pkgAcqMetaSig::GetFinalFilename() const
 {
 {
-   return GetFinalFileNameFromURI(Target->URI);
+   return GetFinalFileNameFromURI(Target.URI);
 }
 }
 std::string pkgAcqBaseIndex::GetFinalFilename() const
 std::string pkgAcqBaseIndex::GetFinalFilename() const
 {
 {
-   return GetFinalFileNameFromURI(Target->URI);
+   return GetFinalFileNameFromURI(Target.URI);
 }
 }
 std::string pkgAcqMetaBase::GetFinalFilename() const
 std::string pkgAcqMetaBase::GetFinalFilename() const
 {
 {
-   return GetFinalFileNameFromURI(DataTarget.URI);
+   return GetFinalFileNameFromURI(Target.URI);
 }
 }
 std::string pkgAcqArchive::GetFinalFilename() const
 std::string pkgAcqArchive::GetFinalFilename() const
 {
 {
@@ -289,17 +289,17 @@ std::string pkgAcqArchive::GetFinalFilename() const
 // pkgAcqTransactionItem::GetMetaKey and specialisations for child classes	/*{{{*/
 // pkgAcqTransactionItem::GetMetaKey and specialisations for child classes	/*{{{*/
 std::string pkgAcqTransactionItem::GetMetaKey() const
 std::string pkgAcqTransactionItem::GetMetaKey() const
 {
 {
-   return Target->MetaKey;
+   return Target.MetaKey;
 }
 }
 std::string pkgAcqIndex::GetMetaKey() const
 std::string pkgAcqIndex::GetMetaKey() const
 {
 {
    if (Stage == STAGE_DECOMPRESS_AND_VERIFY || CurrentCompressionExtension == "uncompressed")
    if (Stage == STAGE_DECOMPRESS_AND_VERIFY || CurrentCompressionExtension == "uncompressed")
-      return Target->MetaKey;
-   return Target->MetaKey + "." + CurrentCompressionExtension;
+      return Target.MetaKey;
+   return Target.MetaKey + "." + CurrentCompressionExtension;
 }
 }
 std::string pkgAcqDiffIndex::GetMetaKey() const
 std::string pkgAcqDiffIndex::GetMetaKey() const
 {
 {
-   return Target->MetaKey + ".diff/Index";
+   return Target.MetaKey + ".diff/Index";
 }
 }
 									/*}}}*/
 									/*}}}*/
 //pkgAcqTransactionItem::TransactionState and specialisations for child classes	/*{{{*/
 //pkgAcqTransactionItem::TransactionState and specialisations for child classes	/*{{{*/
@@ -373,7 +373,7 @@ bool pkgAcqDiffIndex::TransactionState(TransactionStates const state)
       case TransactionCommit:
       case TransactionCommit:
 	 break;
 	 break;
       case TransactionAbort:
       case TransactionAbort:
-	 std::string const Partial = GetPartialFileNameFromURI(Target->URI);
+	 std::string const Partial = GetPartialFileNameFromURI(Target.URI);
 	 unlink(Partial.c_str());
 	 unlink(Partial.c_str());
 	 break;
 	 break;
    }
    }
@@ -396,16 +396,16 @@ class APT_HIDDEN NoActionItem : public pkgAcquire::Item			/*{{{*/
    reach its done state to prevent cleanup deleting the mentioned file.
    reach its done state to prevent cleanup deleting the mentioned file.
    Handy in cases in which we know we have the file already, like IMS-Hits. */
    Handy in cases in which we know we have the file already, like IMS-Hits. */
 {
 {
-   IndexTarget const * const Target;
+   IndexTarget const Target;
    public:
    public:
-   virtual std::string DescURI() const {return Target->URI;};
+   virtual std::string DescURI() const {return Target.URI;};
    virtual HashStringList GetExpectedHashes()  const {return HashStringList();};
    virtual HashStringList GetExpectedHashes()  const {return HashStringList();};
 
 
-   NoActionItem(pkgAcquire * const Owner, IndexTarget const * const Target) :
+   NoActionItem(pkgAcquire * const Owner, IndexTarget const Target) :
       pkgAcquire::Item(Owner), Target(Target)
       pkgAcquire::Item(Owner), Target(Target)
    {
    {
       Status = StatDone;
       Status = StatDone;
-      DestFile = GetFinalFileNameFromURI(Target->URI);
+      DestFile = GetFinalFileNameFromURI(Target.URI);
    }
    }
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -669,7 +669,7 @@ std::string pkgAcquire::Item::HashSum() const				/*{{{*/
 									/*}}}*/
 									/*}}}*/
 
 
 pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner,	/*{{{*/
 pkgAcqTransactionItem::pkgAcqTransactionItem(pkgAcquire * const Owner,	/*{{{*/
-      pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target) :
+      pkgAcqMetaBase * const TransactionManager, IndexTarget const Target) :
    pkgAcquire::Item(Owner), Target(Target), TransactionManager(TransactionManager)
    pkgAcquire::Item(Owner), Target(Target), TransactionManager(TransactionManager)
 {
 {
    if (TransactionManager != this)
    if (TransactionManager != this)
@@ -689,10 +689,10 @@ HashStringList pkgAcqTransactionItem::GetExpectedHashesFor(std::string const Met
 // AcqMetaBase - Constructor						/*{{{*/
 // AcqMetaBase - Constructor						/*{{{*/
 pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner,
 pkgAcqMetaBase::pkgAcqMetaBase(pkgAcquire * const Owner,
       pkgAcqMetaBase * const TransactionManager,
       pkgAcqMetaBase * const TransactionManager,
-      std::vector<IndexTarget*> const * const IndexTargets,
+      std::vector<IndexTarget> const IndexTargets,
       IndexTarget const &DataTarget,
       IndexTarget const &DataTarget,
       indexRecords * const MetaIndexParser)
       indexRecords * const MetaIndexParser)
-: pkgAcqTransactionItem(Owner, TransactionManager, NULL), DataTarget(DataTarget),
+: pkgAcqTransactionItem(Owner, TransactionManager, DataTarget),
    MetaIndexParser(MetaIndexParser), LastMetaIndexParser(NULL), IndexTargets(IndexTargets),
    MetaIndexParser(MetaIndexParser), LastMetaIndexParser(NULL), IndexTargets(IndexTargets),
    AuthPass(false), IMSHit(false)
    AuthPass(false), IMSHit(false)
 {
 {
@@ -953,31 +953,30 @@ void pkgAcqMetaBase::QueueIndexes(bool const verify)			/*{{{*/
    // at this point the real Items are loaded in the fetcher
    // at this point the real Items are loaded in the fetcher
    ExpectedAdditionalItems = 0;
    ExpectedAdditionalItems = 0;
 
 
-   vector <IndexTarget*>::const_iterator Target;
-   for (Target = IndexTargets->begin();
-        Target != IndexTargets->end();
+   for (std::vector <IndexTarget>::const_iterator Target = IndexTargets.begin();
+        Target != IndexTargets.end();
         ++Target)
         ++Target)
    {
    {
       bool trypdiff = _config->FindB("Acquire::PDiffs", true);
       bool trypdiff = _config->FindB("Acquire::PDiffs", true);
       if (verify == true)
       if (verify == true)
       {
       {
-	 if (TransactionManager->MetaIndexParser->Exists((*Target)->MetaKey) == false)
+	 if (TransactionManager->MetaIndexParser->Exists(Target->MetaKey) == false)
 	 {
 	 {
 	    // optional targets that we do not have in the Release file are skipped
 	    // optional targets that we do not have in the Release file are skipped
-	    if ((*Target)->IsOptional)
+	    if (Target->IsOptional)
 	       continue;
 	       continue;
 
 
 	    Status = StatAuthError;
 	    Status = StatAuthError;
-	    strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), (*Target)->MetaKey.c_str());
+	    strprintf(ErrorText, _("Unable to find expected entry '%s' in Release file (Wrong sources.list entry or malformed file)"), Target->MetaKey.c_str());
 	    return;
 	    return;
 	 }
 	 }
 
 
-	 if (RealFileExists(GetFinalFileNameFromURI((*Target)->URI)))
+	 if (RealFileExists(GetFinalFileNameFromURI(Target->URI)))
 	 {
 	 {
 	    if (TransactionManager->LastMetaIndexParser != NULL)
 	    if (TransactionManager->LastMetaIndexParser != NULL)
 	    {
 	    {
-	       HashStringList const newFile = GetExpectedHashesFromFor(TransactionManager->MetaIndexParser, (*Target)->MetaKey);
-	       HashStringList const oldFile = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, (*Target)->MetaKey);
+	       HashStringList const newFile = GetExpectedHashesFromFor(TransactionManager->MetaIndexParser, Target->MetaKey);
+	       HashStringList const oldFile = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, Target->MetaKey);
 	       if (newFile == oldFile)
 	       if (newFile == oldFile)
 	       {
 	       {
 		  // we have the file already, no point in trying to acquire it again
 		  // we have the file already, no point in trying to acquire it again
@@ -990,15 +989,15 @@ void pkgAcqMetaBase::QueueIndexes(bool const verify)			/*{{{*/
 	    trypdiff = false; // no file to patch
 	    trypdiff = false; // no file to patch
 
 
 	 // check if we have patches available
 	 // check if we have patches available
-	 trypdiff &= TransactionManager->MetaIndexParser->Exists((*Target)->MetaKey + ".diff/Index");
+	 trypdiff &= TransactionManager->MetaIndexParser->Exists(Target->MetaKey + ".diff/Index");
       }
       }
       // if we have no file to patch, no point in trying
       // if we have no file to patch, no point in trying
-      trypdiff &= RealFileExists(GetFinalFileNameFromURI((*Target)->URI));
+      trypdiff &= RealFileExists(GetFinalFileNameFromURI(Target->URI));
 
 
       // no point in patching from local sources
       // no point in patching from local sources
       if (trypdiff)
       if (trypdiff)
       {
       {
-	 std::string const proto = (*Target)->URI.substr(0, strlen("file:/"));
+	 std::string const proto = Target->URI.substr(0, strlen("file:/"));
 	 if (proto == "file:/" || proto == "copy:/" || proto == "cdrom:")
 	 if (proto == "file:/" || proto == "copy:/" || proto == "cdrom:")
 	    trypdiff = false;
 	    trypdiff = false;
       }
       }
@@ -1060,7 +1059,7 @@ bool pkgAcqMetaBase::VerifyVendor(string const &Message)		/*{{{*/
 	       // the download progress display (e.g. 7d 3h 42min 1s)
 	       // the download progress display (e.g. 7d 3h 42min 1s)
 	       _("Release file for %s is expired (invalid since %s). "
 	       _("Release file for %s is expired (invalid since %s). "
 		  "Updates for this repository will not be applied."),
 		  "Updates for this repository will not be applied."),
-	       DataTarget.URI.c_str(), TimeToStr(invalid_since).c_str());
+	       Target.URI.c_str(), TimeToStr(invalid_since).c_str());
 	 if (ErrorText.empty())
 	 if (ErrorText.empty())
 	    ErrorText = errmsg;
 	    ErrorText = errmsg;
 	 return _error->Error("%s", errmsg.c_str());
 	 return _error->Error("%s", errmsg.c_str());
@@ -1111,14 +1110,14 @@ bool pkgAcqMetaBase::VerifyVendor(string const &Message)		/*{{{*/
 pkgAcqMetaClearSig::pkgAcqMetaClearSig(pkgAcquire * const Owner,	/*{{{*/
 pkgAcqMetaClearSig::pkgAcqMetaClearSig(pkgAcquire * const Owner,	/*{{{*/
       IndexTarget const &ClearsignedTarget,
       IndexTarget const &ClearsignedTarget,
       IndexTarget const &DetachedDataTarget, IndexTarget const &DetachedSigTarget,
       IndexTarget const &DetachedDataTarget, IndexTarget const &DetachedSigTarget,
-      const vector<IndexTarget*>* const IndexTargets,
+      std::vector<IndexTarget> const IndexTargets,
       indexRecords * const MetaIndexParser) :
       indexRecords * const MetaIndexParser) :
    pkgAcqMetaIndex(Owner, this, ClearsignedTarget, DetachedSigTarget, IndexTargets, MetaIndexParser),
    pkgAcqMetaIndex(Owner, this, ClearsignedTarget, DetachedSigTarget, IndexTargets, MetaIndexParser),
    ClearsignedTarget(ClearsignedTarget),
    ClearsignedTarget(ClearsignedTarget),
    DetachedDataTarget(DetachedDataTarget), DetachedSigTarget(DetachedSigTarget)
    DetachedDataTarget(DetachedDataTarget), DetachedSigTarget(DetachedSigTarget)
 {
 {
    // index targets + (worst case:) Release/Release.gpg
    // index targets + (worst case:) Release/Release.gpg
-   ExpectedAdditionalItems = IndexTargets->size() + 2;
+   ExpectedAdditionalItems = IndexTargets.size() + 2;
    TransactionManager->Add(this);
    TransactionManager->Add(this);
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -1167,8 +1166,8 @@ void pkgAcqMetaClearSig::Done(std::string const &Message,
 	 // We got an InRelease file IMSHit, but we haven't one, which means
 	 // We got an InRelease file IMSHit, but we haven't one, which means
 	 // we had a valid Release/Release.gpg combo stepping in, which we have
 	 // we had a valid Release/Release.gpg combo stepping in, which we have
 	 // to 'acquire' now to ensure list cleanup isn't removing them
 	 // to 'acquire' now to ensure list cleanup isn't removing them
-	 new NoActionItem(Owner, &DetachedDataTarget);
-	 new NoActionItem(Owner, &DetachedSigTarget);
+	 new NoActionItem(Owner, DetachedDataTarget);
+	 new NoActionItem(Owner, DetachedSigTarget);
       }
       }
    }
    }
 }
 }
@@ -1251,7 +1250,7 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire * const Owner,		/*{{{*/
                                  pkgAcqMetaBase * const TransactionManager,
                                  pkgAcqMetaBase * const TransactionManager,
 				 IndexTarget const &DataTarget,
 				 IndexTarget const &DataTarget,
 				 IndexTarget const &DetachedSigTarget,
 				 IndexTarget const &DetachedSigTarget,
-				 vector<IndexTarget*> const * const IndexTargets,
+				 vector<IndexTarget> const IndexTargets,
 				 indexRecords * const MetaIndexParser) :
 				 indexRecords * const MetaIndexParser) :
    pkgAcqMetaBase(Owner, TransactionManager, IndexTargets, DataTarget, MetaIndexParser),
    pkgAcqMetaBase(Owner, TransactionManager, IndexTargets, DataTarget, MetaIndexParser),
    DetachedSigTarget(DetachedSigTarget)
    DetachedSigTarget(DetachedSigTarget)
@@ -1269,7 +1268,7 @@ pkgAcqMetaIndex::pkgAcqMetaIndex(pkgAcquire * const Owner,		/*{{{*/
    Desc.URI = DataTarget.URI;
    Desc.URI = DataTarget.URI;
 
 
    // we expect more item
    // we expect more item
-   ExpectedAdditionalItems = IndexTargets->size();
+   ExpectedAdditionalItems = IndexTargets.size();
    QueueURI(Desc);
    QueueURI(Desc);
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -1284,7 +1283,7 @@ void pkgAcqMetaIndex::Done(string const &Message,			/*{{{*/
       // we have a Release file, now download the Signature, all further
       // we have a Release file, now download the Signature, all further
       // verify/queue for additional downloads will be done in the
       // verify/queue for additional downloads will be done in the
       // pkgAcqMetaSig::Done() code
       // pkgAcqMetaSig::Done() code
-      new pkgAcqMetaSig(Owner, TransactionManager, &DetachedSigTarget, this);
+      new pkgAcqMetaSig(Owner, TransactionManager, DetachedSigTarget, this);
    }
    }
 }
 }
 									/*}}}*/
 									/*}}}*/
@@ -1297,7 +1296,7 @@ void pkgAcqMetaIndex::Failed(string const &Message,
 
 
    _error->Warning(_("The repository '%s' does not have a Release file. "
    _error->Warning(_("The repository '%s' does not have a Release file. "
                      "This is deprecated, please contact the owner of the "
                      "This is deprecated, please contact the owner of the "
-                     "repository."), DataTarget.Description.c_str());
+                     "repository."), Target.Description.c_str());
 
 
    // No Release file was present so fall
    // No Release file was present so fall
    // back to queueing Packages files without verification
    // back to queueing Packages files without verification
@@ -1325,18 +1324,18 @@ void pkgAcqMetaIndex::Finished()					/*{{{*/
 									/*}}}*/
 									/*}}}*/
 std::string pkgAcqMetaIndex::DescURI() const				/*{{{*/
 std::string pkgAcqMetaIndex::DescURI() const				/*{{{*/
 {
 {
-   return DataTarget.URI;
+   return Target.URI;
 }
 }
 									/*}}}*/
 									/*}}}*/
 
 
 // AcqMetaSig::AcqMetaSig - Constructor					/*{{{*/
 // AcqMetaSig::AcqMetaSig - Constructor					/*{{{*/
 pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire * const Owner,
 pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire * const Owner,
       pkgAcqMetaBase * const TransactionManager,
       pkgAcqMetaBase * const TransactionManager,
-      IndexTarget const * const Target,
+      IndexTarget const Target,
       pkgAcqMetaIndex * const MetaIndex) :
       pkgAcqMetaIndex * const MetaIndex) :
    pkgAcqTransactionItem(Owner, TransactionManager, Target), MetaIndex(MetaIndex)
    pkgAcqTransactionItem(Owner, TransactionManager, Target), MetaIndex(MetaIndex)
 {
 {
-   DestFile = GetPartialFileNameFromURI(Target->URI);
+   DestFile = GetPartialFileNameFromURI(Target.URI);
 
 
    // remove any partial downloaded sig-file in partial/.
    // remove any partial downloaded sig-file in partial/.
    // it may confuse proxies and is too small to warrant a
    // it may confuse proxies and is too small to warrant a
@@ -1349,10 +1348,10 @@ pkgAcqMetaSig::pkgAcqMetaSig(pkgAcquire * const Owner,
                 << TransactionManager << std::endl;
                 << TransactionManager << std::endl;
 
 
    // Create the item
    // Create the item
-   Desc.Description = Target->Description;
+   Desc.Description = Target.Description;
    Desc.Owner = this;
    Desc.Owner = this;
-   Desc.ShortDesc = Target->ShortDesc;
-   Desc.URI = Target->URI;
+   Desc.ShortDesc = Target.ShortDesc;
+   Desc.URI = Target.URI;
 
 
    // If we got a hit for Release, we will get one for Release.gpg too (or obscure errors),
    // If we got a hit for Release, we will get one for Release.gpg too (or obscure errors),
    // so we skip the download step and go instantly to verification
    // so we skip the download step and go instantly to verification
@@ -1420,7 +1419,7 @@ void pkgAcqMetaSig::Failed(string const &Message,pkgAcquire::MethodConfig const
    {
    {
       std::string downgrade_msg;
       std::string downgrade_msg;
       strprintf(downgrade_msg, _("The repository '%s' is no longer signed."),
       strprintf(downgrade_msg, _("The repository '%s' is no longer signed."),
-                MetaIndex->DataTarget.Description.c_str());
+                MetaIndex->Target.Description.c_str());
       if(_config->FindB("Acquire::AllowDowngradeToInsecureRepositories"))
       if(_config->FindB("Acquire::AllowDowngradeToInsecureRepositories"))
       {
       {
          // meh, the users wants to take risks (we still mark the packages
          // meh, the users wants to take risks (we still mark the packages
@@ -1442,7 +1441,7 @@ void pkgAcqMetaSig::Failed(string const &Message,pkgAcquire::MethodConfig const
    else
    else
       _error->Warning(_("The data from '%s' is not signed. Packages "
       _error->Warning(_("The data from '%s' is not signed. Packages "
 	       "from that repository can not be authenticated."),
 	       "from that repository can not be authenticated."),
-	    MetaIndex->DataTarget.Description.c_str());
+	    MetaIndex->Target.Description.c_str());
 
 
    // ensures that a Release.gpg file in the lists/ is removed by the transaction
    // ensures that a Release.gpg file in the lists/ is removed by the transaction
    TransactionManager->TransactionStageRemoval(this, DestFile);
    TransactionManager->TransactionStageRemoval(this, DestFile);
@@ -1495,7 +1494,7 @@ void pkgAcqMetaSig::Failed(string const &Message,pkgAcquire::MethodConfig const
 // AcqBaseIndex - Constructor						/*{{{*/
 // AcqBaseIndex - Constructor						/*{{{*/
 pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
 pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
       pkgAcqMetaBase * const TransactionManager,
       pkgAcqMetaBase * const TransactionManager,
-      IndexTarget const * const Target)
+      IndexTarget const Target)
 : pkgAcqTransactionItem(Owner, TransactionManager, Target)
 : pkgAcqTransactionItem(Owner, TransactionManager, Target)
 {
 {
 }
 }
@@ -1510,15 +1509,15 @@ pkgAcqBaseIndex::pkgAcqBaseIndex(pkgAcquire * const Owner,
  */
  */
 pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire * const Owner,
 pkgAcqDiffIndex::pkgAcqDiffIndex(pkgAcquire * const Owner,
                                  pkgAcqMetaBase * const TransactionManager,
                                  pkgAcqMetaBase * const TransactionManager,
-                                 IndexTarget const * const Target)
+                                 IndexTarget const Target)
    : pkgAcqBaseIndex(Owner, TransactionManager, Target)
    : pkgAcqBaseIndex(Owner, TransactionManager, Target)
 {
 {
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
 
    Desc.Owner = this;
    Desc.Owner = this;
-   Desc.Description = Target->Description + ".diff/Index";
-   Desc.ShortDesc = Target->ShortDesc;
-   Desc.URI = Target->URI + ".diff/Index";
+   Desc.Description = Target.Description + ".diff/Index";
+   Desc.ShortDesc = Target.ShortDesc;
+   Desc.URI = Target.URI + ".diff/Index";
 
 
    DestFile = GetPartialFileNameFromURI(Desc.URI);
    DestFile = GetPartialFileNameFromURI(Desc.URI);
 
 
@@ -1599,8 +1598,8 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile)	/*{{{*/
       return false;
       return false;
    }
    }
 
 
-   std::string const CurrentPackagesFile = GetFinalFileNameFromURI(Target->URI);
-   HashStringList const TargetFileHashes = GetExpectedHashesFor(Target->MetaKey);
+   std::string const CurrentPackagesFile = GetFinalFileNameFromURI(Target.URI);
+   HashStringList const TargetFileHashes = GetExpectedHashesFor(Target.MetaKey);
    if (TargetFileHashes.usable() == false || ServerHashes != TargetFileHashes)
    if (TargetFileHashes.usable() == false || ServerHashes != TargetFileHashes)
    {
    {
       if (Debug == true)
       if (Debug == true)
@@ -1614,7 +1613,7 @@ bool pkgAcqDiffIndex::ParseDiffIndex(string const &IndexDiffFile)	/*{{{*/
    HashStringList LocalHashes;
    HashStringList LocalHashes;
    // try avoiding calculating the hash here as this is costly
    // try avoiding calculating the hash here as this is costly
    if (TransactionManager->LastMetaIndexParser != NULL)
    if (TransactionManager->LastMetaIndexParser != NULL)
-      LocalHashes = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, Target->MetaKey);
+      LocalHashes = GetExpectedHashesFromFor(TransactionManager->LastMetaIndexParser, Target.MetaKey);
    if (LocalHashes.usable() == false)
    if (LocalHashes.usable() == false)
    {
    {
       FileFd fd(CurrentPackagesFile, FileFd::ReadOnly);
       FileFd fd(CurrentPackagesFile, FileFd::ReadOnly);
@@ -1910,29 +1909,29 @@ void pkgAcqDiffIndex::Done(string const &Message,HashStringList const &Hashes,	/
  */
  */
 pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
 pkgAcqIndexDiffs::pkgAcqIndexDiffs(pkgAcquire * const Owner,
                                    pkgAcqMetaBase * const TransactionManager,
                                    pkgAcqMetaBase * const TransactionManager,
-                                   IndexTarget const * const Target,
+                                   IndexTarget const Target,
 				   vector<DiffInfo> const &diffs)
 				   vector<DiffInfo> const &diffs)
    : pkgAcqBaseIndex(Owner, TransactionManager, Target),
    : pkgAcqBaseIndex(Owner, TransactionManager, Target),
      available_patches(diffs)
      available_patches(diffs)
 {
 {
-   DestFile = GetPartialFileNameFromURI(Target->URI);
+   DestFile = GetPartialFileNameFromURI(Target.URI);
 
 
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
 
    Desc.Owner = this;
    Desc.Owner = this;
-   Description = Target->Description;
-   Desc.ShortDesc = Target->ShortDesc;
+   Description = Target.Description;
+   Desc.ShortDesc = Target.ShortDesc;
 
 
    if(available_patches.empty() == true)
    if(available_patches.empty() == true)
    {
    {
       // we are done (yeah!), check hashes against the final file
       // we are done (yeah!), check hashes against the final file
-      DestFile = GetFinalFileNameFromURI(Target->URI);
+      DestFile = GetFinalFileNameFromURI(Target.URI);
       Finish(true);
       Finish(true);
    }
    }
    else
    else
    {
    {
       // patching needs to be bootstrapped with the 'old' version
       // patching needs to be bootstrapped with the 'old' version
-      std::string const PartialFile = GetPartialFileNameFromURI(Target->URI);
+      std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
       if (RealFileExists(PartialFile) == false)
       if (RealFileExists(PartialFile) == false)
       {
       {
 	 if (symlink(GetFinalFilename().c_str(), PartialFile.c_str()) != 0)
 	 if (symlink(GetFinalFilename().c_str(), PartialFile.c_str()) != 0)
@@ -1956,7 +1955,7 @@ void pkgAcqIndexDiffs::Failed(string const &Message,pkgAcquire::MethodConfig con
    if(Debug)
    if(Debug)
       std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl
       std::clog << "pkgAcqIndexDiffs failed: " << Desc.URI << " with " << Message << std::endl
 		<< "Falling back to normal index file acquire" << std::endl;
 		<< "Falling back to normal index file acquire" << std::endl;
-   DestFile = GetPartialFileNameFromURI(Target->URI);
+   DestFile = GetPartialFileNameFromURI(Target.URI);
    RenameOnError(PDiffError);
    RenameOnError(PDiffError);
    std::string const patchname = GetDiffsPatchFileName(DestFile);
    std::string const patchname = GetDiffsPatchFileName(DestFile);
    if (RealFileExists(patchname))
    if (RealFileExists(patchname))
@@ -1999,7 +1998,7 @@ void pkgAcqIndexDiffs::Finish(bool allDone)
 bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
 bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
 {
 {
    // calc sha1 of the just patched file
    // calc sha1 of the just patched file
-   std::string const FinalFile = GetPartialFileNameFromURI(Target->URI);
+   std::string const FinalFile = GetPartialFileNameFromURI(Target.URI);
 
 
    if(!FileExists(FinalFile))
    if(!FileExists(FinalFile))
    {
    {
@@ -2015,7 +2014,7 @@ bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
    if(Debug)
    if(Debug)
       std::clog << "QueueNextDiff: " << FinalFile << " (" << LocalHashes.find(NULL)->toStr() << ")" << std::endl;
       std::clog << "QueueNextDiff: " << FinalFile << " (" << LocalHashes.find(NULL)->toStr() << ")" << std::endl;
 
 
-   HashStringList const TargetFileHashes = GetExpectedHashesFor(Target->MetaKey);
+   HashStringList const TargetFileHashes = GetExpectedHashesFor(Target.MetaKey);
    if (unlikely(LocalHashes.usable() == false || TargetFileHashes.usable() == false))
    if (unlikely(LocalHashes.usable() == false || TargetFileHashes.usable() == false))
    {
    {
       Failed("Local/Expected hashes are not usable", NULL);
       Failed("Local/Expected hashes are not usable", NULL);
@@ -2049,9 +2048,9 @@ bool pkgAcqIndexDiffs::QueueNextDiff()					/*{{{*/
    }
    }
 
 
    // queue the right diff
    // queue the right diff
-   Desc.URI = Target->URI + ".diff/" + available_patches[0].file + ".gz";
+   Desc.URI = Target.URI + ".diff/" + available_patches[0].file + ".gz";
    Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
    Desc.Description = Description + " " + available_patches[0].file + string(".pdiff");
-   DestFile = GetPartialFileNameFromURI(Target->URI + ".diff/" + available_patches[0].file);
+   DestFile = GetPartialFileNameFromURI(Target.URI + ".diff/" + available_patches[0].file);
 
 
    if(Debug)
    if(Debug)
       std::clog << "pkgAcqIndexDiffs::QueueNextDiff(): " << Desc.URI << std::endl;
       std::clog << "pkgAcqIndexDiffs::QueueNextDiff(): " << Desc.URI << std::endl;
@@ -2069,7 +2068,7 @@ void pkgAcqIndexDiffs::Done(string const &Message, HashStringList const &Hashes,
 
 
    Item::Done(Message, Hashes, Cnf);
    Item::Done(Message, Hashes, Cnf);
 
 
-   std::string const FinalFile = GetPartialFileNameFromURI(Target->URI);
+   std::string const FinalFile = GetPartialFileNameFromURI(Target.URI);
    std::string const PatchFile = GetDiffsPatchFileName(FinalFile);
    std::string const PatchFile = GetDiffsPatchFileName(FinalFile);
 
 
    // success in downloading a diff, enter ApplyDiff state
    // success in downloading a diff, enter ApplyDiff state
@@ -2132,7 +2131,7 @@ std::string pkgAcqIndexDiffs::Custom600Headers() const			/*{{{*/
 // AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor			/*{{{*/
 // AcqIndexMergeDiffs::AcqIndexMergeDiffs - Constructor			/*{{{*/
 pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner,
 pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner,
                                              pkgAcqMetaBase * const TransactionManager,
                                              pkgAcqMetaBase * const TransactionManager,
-                                             IndexTarget const * const Target,
+                                             IndexTarget const Target,
                                              DiffInfo const &patch,
                                              DiffInfo const &patch,
                                              std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
                                              std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches)
   : pkgAcqBaseIndex(Owner, TransactionManager, Target),
   : pkgAcqBaseIndex(Owner, TransactionManager, Target),
@@ -2141,13 +2140,13 @@ pkgAcqIndexMergeDiffs::pkgAcqIndexMergeDiffs(pkgAcquire * const Owner,
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
    Debug = _config->FindB("Debug::pkgAcquire::Diffs",false);
 
 
    Desc.Owner = this;
    Desc.Owner = this;
-   Description = Target->Description;
-   Desc.ShortDesc = Target->ShortDesc;
+   Description = Target.Description;
+   Desc.ShortDesc = Target.ShortDesc;
 
 
-   Desc.URI = Target->URI + ".diff/" + patch.file + ".gz";
+   Desc.URI = Target.URI + ".diff/" + patch.file + ".gz";
    Desc.Description = Description + " " + patch.file + string(".pdiff");
    Desc.Description = Description + " " + patch.file + string(".pdiff");
 
 
-   DestFile = GetPartialFileNameFromURI(Target->URI + ".diff/" + patch.file);
+   DestFile = GetPartialFileNameFromURI(Target.URI + ".diff/" + patch.file);
 
 
    if(Debug)
    if(Debug)
       std::clog << "pkgAcqIndexMergeDiffs: " << Desc.URI << std::endl;
       std::clog << "pkgAcqIndexMergeDiffs: " << Desc.URI << std::endl;
@@ -2174,7 +2173,7 @@ void pkgAcqIndexMergeDiffs::Failed(string const &Message,pkgAcquire::MethodConfi
    State = StateErrorDiff;
    State = StateErrorDiff;
    if (Debug)
    if (Debug)
       std::clog << "Falling back to normal index file acquire" << std::endl;
       std::clog << "Falling back to normal index file acquire" << std::endl;
-   DestFile = GetPartialFileNameFromURI(Target->URI);
+   DestFile = GetPartialFileNameFromURI(Target.URI);
    RenameOnError(PDiffError);
    RenameOnError(PDiffError);
    std::string const patchname = GetMergeDiffsPatchFileName(DestFile, patch.file);
    std::string const patchname = GetMergeDiffsPatchFileName(DestFile, patch.file);
    if (RealFileExists(patchname))
    if (RealFileExists(patchname))
@@ -2190,7 +2189,7 @@ void pkgAcqIndexMergeDiffs::Done(string const &Message, HashStringList const &Ha
 
 
    Item::Done(Message, Hashes, Cnf);
    Item::Done(Message, Hashes, Cnf);
 
 
-   string const FinalFile = GetPartialFileNameFromURI(Target->URI);
+   string const FinalFile = GetPartialFileNameFromURI(Target.URI);
    if (State == StateFetchDiff)
    if (State == StateFetchDiff)
    {
    {
       Rename(DestFile, GetMergeDiffsPatchFileName(FinalFile, patch.file));
       Rename(DestFile, GetMergeDiffsPatchFileName(FinalFile, patch.file));
@@ -2241,7 +2240,7 @@ void pkgAcqIndexMergeDiffs::Done(string const &Message, HashStringList const &Ha
       for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
       for (std::vector<pkgAcqIndexMergeDiffs *>::const_iterator I = allPatches->begin();
 	    I != allPatches->end(); ++I)
 	    I != allPatches->end(); ++I)
       {
       {
-	 std::string const PartialFile = GetPartialFileNameFromURI(Target->URI);
+	 std::string const PartialFile = GetPartialFileNameFromURI(Target.URI);
 	 std::string const patch = GetMergeDiffsPatchFileName(PartialFile, (*I)->patch.file);
 	 std::string const patch = GetMergeDiffsPatchFileName(PartialFile, (*I)->patch.file);
 	 unlink(patch.c_str());
 	 unlink(patch.c_str());
       }
       }
@@ -2276,12 +2275,12 @@ std::string pkgAcqIndexMergeDiffs::Custom600Headers() const		/*{{{*/
 // AcqIndex::AcqIndex - Constructor					/*{{{*/
 // AcqIndex::AcqIndex - Constructor					/*{{{*/
 pkgAcqIndex::pkgAcqIndex(pkgAcquire * const Owner,
 pkgAcqIndex::pkgAcqIndex(pkgAcquire * const Owner,
                          pkgAcqMetaBase * const TransactionManager,
                          pkgAcqMetaBase * const TransactionManager,
-                         IndexTarget const * const Target)
+                         IndexTarget const Target)
    : pkgAcqBaseIndex(Owner, TransactionManager, Target)
    : pkgAcqBaseIndex(Owner, TransactionManager, Target)
 {
 {
    // autoselect the compression method
    // autoselect the compression method
    AutoSelectCompression();
    AutoSelectCompression();
-   Init(Target->URI, Target->Description, Target->ShortDesc);
+   Init(Target.URI, Target.Description, Target.ShortDesc);
 
 
    if(_config->FindB("Debug::Acquire::Transaction", false) == true)
    if(_config->FindB("Debug::Acquire::Transaction", false) == true)
       std::clog << "New pkgIndex with TransactionManager "
       std::clog << "New pkgIndex with TransactionManager "
@@ -2293,12 +2292,12 @@ void pkgAcqIndex::AutoSelectCompression()
 {
 {
    std::vector<std::string> types = APT::Configuration::getCompressionTypes();
    std::vector<std::string> types = APT::Configuration::getCompressionTypes();
    CompressionExtensions = "";
    CompressionExtensions = "";
-   if (TransactionManager->MetaIndexParser != NULL && TransactionManager->MetaIndexParser->Exists(Target->MetaKey))
+   if (TransactionManager->MetaIndexParser != NULL && TransactionManager->MetaIndexParser->Exists(Target.MetaKey))
    {
    {
       for (std::vector<std::string>::const_iterator t = types.begin();
       for (std::vector<std::string>::const_iterator t = types.begin();
            t != types.end(); ++t)
            t != types.end(); ++t)
       {
       {
-         std::string CompressedMetaKey = string(Target->MetaKey).append(".").append(*t);
+         std::string CompressedMetaKey = string(Target.MetaKey).append(".").append(*t);
          if (*t == "uncompressed" ||
          if (*t == "uncompressed" ||
              TransactionManager->MetaIndexParser->Exists(CompressedMetaKey) == true)
              TransactionManager->MetaIndexParser->Exists(CompressedMetaKey) == true)
             CompressionExtensions.append(*t).append(" ");
             CompressionExtensions.append(*t).append(" ");
@@ -2397,7 +2396,7 @@ string pkgAcqIndex::Custom600Headers() const
    if (stat(Final.c_str(),&Buf) == 0)
    if (stat(Final.c_str(),&Buf) == 0)
       msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
       msg += "\nLast-Modified: " + TimeRFC1123(Buf.st_mtime);
 
 
-   if(Target->IsOptional)
+   if(Target.IsOptional)
       msg += "\nFail-Ignore: true";
       msg += "\nFail-Ignore: true";
 
 
    return msg;
    return msg;
@@ -2413,13 +2412,13 @@ void pkgAcqIndex::Failed(string const &Message,pkgAcquire::MethodConfig const *
    {
    {
       if (CompressionExtensions.empty() == false)
       if (CompressionExtensions.empty() == false)
       {
       {
-	 Init(Target->URI, Desc.Description, Desc.ShortDesc);
+	 Init(Target.URI, Desc.Description, Desc.ShortDesc);
 	 Status = StatIdle;
 	 Status = StatIdle;
 	 return;
 	 return;
       }
       }
    }
    }
 
 
-   if(Target->IsOptional && GetExpectedHashes().empty() && Stage == STAGE_DOWNLOAD)
+   if(Target.IsOptional && GetExpectedHashes().empty() && Stage == STAGE_DOWNLOAD)
       Status = StatDone;
       Status = StatDone;
    else
    else
       TransactionManager->AbortTransaction();
       TransactionManager->AbortTransaction();
@@ -2430,7 +2429,7 @@ void pkgAcqIndex::ReverifyAfterIMS()
 {
 {
    // update destfile to *not* include the compression extension when doing
    // update destfile to *not* include the compression extension when doing
    // a reverify (as its uncompressed on disk already)
    // a reverify (as its uncompressed on disk already)
-   DestFile = GetCompressedFileName(Target->URI, GetPartialFileNameFromURI(Target->URI), CurrentCompressionExtension);
+   DestFile = GetCompressedFileName(Target.URI, GetPartialFileNameFromURI(Target.URI), CurrentCompressionExtension);
 
 
    // copy FinalFile into partial/ so that we check the hash again
    // copy FinalFile into partial/ so that we check the hash again
    string FinalFile = GetFinalFilename();
    string FinalFile = GetFinalFilename();
@@ -2509,7 +2508,7 @@ void pkgAcqIndex::StageDownloadDone(string const &Message, HashStringList const
    // If we have compressed indexes enabled, queue for hash verification
    // If we have compressed indexes enabled, queue for hash verification
    if (_config->FindB("Acquire::GzipIndexes",false))
    if (_config->FindB("Acquire::GzipIndexes",false))
    {
    {
-      DestFile = GetPartialFileNameFromURI(Target->URI + '.' + CurrentCompressionExtension);
+      DestFile = GetPartialFileNameFromURI(Target.URI + '.' + CurrentCompressionExtension);
       EraseFileName = "";
       EraseFileName = "";
       Stage = STAGE_DECOMPRESS_AND_VERIFY;
       Stage = STAGE_DECOMPRESS_AND_VERIFY;
       Desc.URI = "copy:" + FileName;
       Desc.URI = "copy:" + FileName;

+ 22 - 24
apt-pkg/acquire-item.h

@@ -55,23 +55,23 @@ class IndexTarget							/*{{{*/
 {
 {
    public:
    public:
    /** \brief A URI from which the index file can be downloaded. */
    /** \brief A URI from which the index file can be downloaded. */
-   std::string const URI;
+   std::string URI;
 
 
    /** \brief A description of the index file. */
    /** \brief A description of the index file. */
-   std::string const Description;
+   std::string Description;
 
 
    /** \brief A shorter description of the index file. */
    /** \brief A shorter description of the index file. */
-   std::string const ShortDesc;
+   std::string ShortDesc;
 
 
    /** \brief The key by which this index file should be
    /** \brief The key by which this index file should be
        looked up within the meta index file. */
        looked up within the meta index file. */
-   std::string const MetaKey;
+   std::string MetaKey;
 
 
    /** \brief Is it okay if the file isn't found in the meta index */
    /** \brief Is it okay if the file isn't found in the meta index */
-   bool const IsOptional;
+   bool IsOptional;
 
 
    /** \brief Target specific options defined by the implementation */
    /** \brief Target specific options defined by the implementation */
-   std::map<std::string, std::string> const Options;
+   std::map<std::string, std::string> Options;
 
 
    IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
    IndexTarget(std::string const &MetaKey, std::string const &ShortDesc,
 	 std::string const &LongDesc, std::string const &URI, bool const IsOptional,
 	 std::string const &LongDesc, std::string const &URI, bool const IsOptional,
@@ -374,7 +374,7 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item		/*{{{*/
 /** \brief baseclass for the indexes files to manage them all together */
 /** \brief baseclass for the indexes files to manage them all together */
 {
 {
    protected:
    protected:
-   IndexTarget const * const Target;
+   IndexTarget const Target;
    HashStringList GetExpectedHashesFor(std::string const MetaKey) const;
    HashStringList GetExpectedHashesFor(std::string const MetaKey) const;
 
 
    bool QueueURI(pkgAcquire::ItemDesc &Item);
    bool QueueURI(pkgAcquire::ItemDesc &Item);
@@ -392,13 +392,13 @@ class APT_HIDDEN pkgAcqTransactionItem: public pkgAcquire::Item		/*{{{*/
    };
    };
    virtual bool TransactionState(TransactionStates const state);
    virtual bool TransactionState(TransactionStates const state);
 
 
-   virtual std::string DescURI() const { return Target->URI; }
+   virtual std::string DescURI() const { return Target.URI; }
    virtual HashStringList GetExpectedHashes() const;
    virtual HashStringList GetExpectedHashes() const;
    virtual std::string GetMetaKey() const;
    virtual std::string GetMetaKey() const;
    virtual bool HashesRequired() const;
    virtual bool HashesRequired() const;
 
 
 
 
-   pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target);
+   pkgAcqTransactionItem(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target);
    virtual ~pkgAcqTransactionItem();
    virtual ~pkgAcqTransactionItem();
 
 
    friend class pkgAcqMetaBase;
    friend class pkgAcqMetaBase;
@@ -412,7 +412,6 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem		/*{{{*/
  protected:
  protected:
    std::vector<pkgAcqTransactionItem*> Transaction;
    std::vector<pkgAcqTransactionItem*> Transaction;
 
 
-   IndexTarget const DataTarget;
  public:
  public:
    /** \brief A package-system-specific parser for the meta-index file. */
    /** \brief A package-system-specific parser for the meta-index file. */
    indexRecords *MetaIndexParser;
    indexRecords *MetaIndexParser;
@@ -422,7 +421,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem		/*{{{*/
    /** \brief The index files which should be looked up in the meta-index
    /** \brief The index files which should be looked up in the meta-index
     *  and then downloaded.
     *  and then downloaded.
     */
     */
-   const std::vector<IndexTarget*>* const IndexTargets;
+   std::vector<IndexTarget> const IndexTargets;
 
 
    /** \brief If \b true, the index's signature is currently being verified.
    /** \brief If \b true, the index's signature is currently being verified.
     */
     */
@@ -504,7 +503,7 @@ class APT_HIDDEN pkgAcqMetaBase : public pkgAcqTransactionItem		/*{{{*/
    virtual std::string GetFinalFilename() const;
    virtual std::string GetFinalFilename() const;
 
 
    pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
    pkgAcqMetaBase(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-		  std::vector<IndexTarget*> const * const IndexTargets,
+		  std::vector<IndexTarget> const IndexTargets,
 		  IndexTarget const &DataTarget,
 		  IndexTarget const &DataTarget,
 		  indexRecords* const MetaIndexParser);
 		  indexRecords* const MetaIndexParser);
 };
 };
@@ -541,7 +540,7 @@ class APT_HIDDEN pkgAcqMetaIndex : public pkgAcqMetaBase
    /** \brief Create a new pkgAcqMetaIndex. */
    /** \brief Create a new pkgAcqMetaIndex. */
    pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
    pkgAcqMetaIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
 		   IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
 		   IndexTarget const &DataTarget, IndexTarget const &DetachedSigTarget,
-		   const std::vector<IndexTarget*>* const IndexTargets, indexRecords * const MetaIndexParser);
+		   std::vector<IndexTarget> const IndexTargets, indexRecords * const MetaIndexParser);
 
 
    friend class pkgAcqMetaSig;
    friend class pkgAcqMetaSig;
 };
 };
@@ -577,7 +576,7 @@ class APT_HIDDEN pkgAcqMetaSig : public pkgAcqTransactionItem
 		     pkgAcquire::MethodConfig const * const Cnf);
 		     pkgAcquire::MethodConfig const * const Cnf);
 
 
    /** \brief Create a new pkgAcqMetaSig. */
    /** \brief Create a new pkgAcqMetaSig. */
-   pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const * const Target,
+   pkgAcqMetaSig(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager, IndexTarget const Target,
 	 pkgAcqMetaIndex * const MetaIndex);
 	 pkgAcqMetaIndex * const MetaIndex);
    virtual ~pkgAcqMetaSig();
    virtual ~pkgAcqMetaSig();
 };
 };
@@ -602,7 +601,7 @@ public:
 		IndexTarget const &ClearsignedTarget,
 		IndexTarget const &ClearsignedTarget,
 		IndexTarget const &DetachedDataTarget,
 		IndexTarget const &DetachedDataTarget,
 		IndexTarget const &DetachedSigTarget,
 		IndexTarget const &DetachedSigTarget,
-		std::vector<IndexTarget*> const * const IndexTargets,
+		std::vector<IndexTarget> const IndexTargets,
 		indexRecords * const MetaIndexParser);
 		indexRecords * const MetaIndexParser);
    virtual ~pkgAcqMetaClearSig();
    virtual ~pkgAcqMetaClearSig();
 };
 };
@@ -617,7 +616,7 @@ class APT_HIDDEN pkgAcqBaseIndex : public pkgAcqTransactionItem
    virtual std::string GetFinalFilename() const;
    virtual std::string GetFinalFilename() const;
 
 
    pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
    pkgAcqBaseIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                   IndexTarget const * const Target);
+                   IndexTarget const Target);
 };
 };
 									/*}}}*/
 									/*}}}*/
 /** \brief An item that is responsible for fetching an index file of	{{{
 /** \brief An item that is responsible for fetching an index file of	{{{
@@ -653,7 +652,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
    virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf);
    virtual void Failed(std::string const &Message, pkgAcquire::MethodConfig const * const Cnf);
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
 		     pkgAcquire::MethodConfig const * const Cnf);
 		     pkgAcquire::MethodConfig const * const Cnf);
-   virtual std::string DescURI() const {return Target->URI + "Index";};
+   virtual std::string DescURI() const {return Target.URI + "Index";};
    virtual std::string Custom600Headers() const;
    virtual std::string Custom600Headers() const;
    virtual std::string GetMetaKey() const;
    virtual std::string GetMetaKey() const;
 
 
@@ -680,7 +679,7 @@ class APT_HIDDEN pkgAcqDiffIndex : public pkgAcqBaseIndex
     *  \param ShortDesc A short description of the list file to download.
     *  \param ShortDesc A short description of the list file to download.
     */
     */
    pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
    pkgAcqDiffIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                   IndexTarget const * const Target);
+                   IndexTarget const Target);
  private:
  private:
    APT_HIDDEN void QueueOnIMSHit() const;
    APT_HIDDEN void QueueOnIMSHit() const;
 };
 };
@@ -756,7 +755,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
 	 pkgAcquire::MethodConfig const * const Cnf);
 	 pkgAcquire::MethodConfig const * const Cnf);
    virtual std::string Custom600Headers() const;
    virtual std::string Custom600Headers() const;
-   virtual std::string DescURI() const {return Target->URI + "Index";};
+   virtual std::string DescURI() const {return Target.URI + "Index";};
    virtual HashStringList GetExpectedHashes() const;
    virtual HashStringList GetExpectedHashes() const;
    virtual bool HashesRequired() const;
    virtual bool HashesRequired() const;
 
 
@@ -778,8 +777,7 @@ class APT_HIDDEN pkgAcqIndexMergeDiffs : public pkgAcqBaseIndex
     *  check if it was the last one to complete the download step
     *  check if it was the last one to complete the download step
     */
     */
    pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
    pkgAcqIndexMergeDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                         IndexTarget const * const Target,
-                         DiffInfo const &patch,
+                         IndexTarget const Target, DiffInfo const &patch,
                          std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
                          std::vector<pkgAcqIndexMergeDiffs*> const * const allPatches);
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -869,7 +867,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
    virtual void Done(std::string const &Message, HashStringList const &Hashes,
 		     pkgAcquire::MethodConfig const * const Cnf);
 		     pkgAcquire::MethodConfig const * const Cnf);
    virtual std::string Custom600Headers() const;
    virtual std::string Custom600Headers() const;
-   virtual std::string DescURI() const {return Target->URI + "IndexDiffs";};
+   virtual std::string DescURI() const {return Target.URI + "IndexDiffs";};
    virtual HashStringList GetExpectedHashes() const;
    virtual HashStringList GetExpectedHashes() const;
    virtual bool HashesRequired() const;
    virtual bool HashesRequired() const;
 
 
@@ -892,7 +890,7 @@ class APT_HIDDEN pkgAcqIndexDiffs : public pkgAcqBaseIndex
     *  that depends on it.
     *  that depends on it.
     */
     */
    pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
    pkgAcqIndexDiffs(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-                    IndexTarget const * const Target,
+                    IndexTarget const Target,
 		    std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>());
 		    std::vector<DiffInfo> const &diffs=std::vector<DiffInfo>());
 };
 };
 									/*}}}*/
 									/*}}}*/
@@ -969,7 +967,7 @@ class APT_HIDDEN pkgAcqIndex : public pkgAcqBaseIndex
    virtual std::string GetMetaKey() const;
    virtual std::string GetMetaKey() const;
 
 
    pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
    pkgAcqIndex(pkgAcquire * const Owner, pkgAcqMetaBase * const TransactionManager,
-               IndexTarget const * const Target);
+               IndexTarget const Target);
 
 
    void Init(std::string const &URI, std::string const &URIDesc,
    void Init(std::string const &URI, std::string const &URIDesc,
              std::string const &ShortDesc);
              std::string const &ShortDesc);

+ 7 - 9
apt-pkg/deb/debmetaindex.cc

@@ -93,7 +93,7 @@ debReleaseIndex::~debReleaseIndex() {
 template<typename CallC>
 template<typename CallC>
 void foreachTarget(std::string const URI, std::string const Dist,
 void foreachTarget(std::string const URI, std::string const Dist,
       std::map<std::string, std::vector<debReleaseIndex::debSectionEntry const *> > const &ArchEntries,
       std::map<std::string, std::vector<debReleaseIndex::debSectionEntry const *> > const &ArchEntries,
-      CallC Call)
+      CallC &Call)
 {
 {
    bool const flatArchive = (Dist[Dist.length() - 1] == '/');
    bool const flatArchive = (Dist[Dist.length() - 1] == '/');
    std::string baseURI = URI;
    std::string baseURI = URI;
@@ -206,7 +206,7 @@ void foreachTarget(std::string const URI, std::string const Dist,
 
 
 struct ComputeIndexTargetsClass
 struct ComputeIndexTargetsClass
 {
 {
-   vector <IndexTarget *> * const IndexTargets;
+   vector <IndexTarget> IndexTargets;
 
 
    void operator()(std::string MetaKey, std::string ShortDesc, std::string LongDesc,
    void operator()(std::string MetaKey, std::string ShortDesc, std::string LongDesc,
 	 bool const IsOptional, std::map<std::string, std::string> Options)
 	 bool const IsOptional, std::map<std::string, std::string> Options)
@@ -217,7 +217,7 @@ struct ComputeIndexTargetsClass
 	 ShortDesc = SubstVar(ShortDesc, std::string("$(") + O->first + ")", O->second);
 	 ShortDesc = SubstVar(ShortDesc, std::string("$(") + O->first + ")", O->second);
 	 LongDesc = SubstVar(LongDesc, std::string("$(") + O->first + ")", O->second);
 	 LongDesc = SubstVar(LongDesc, std::string("$(") + O->first + ")", O->second);
       }
       }
-      IndexTarget * Target = new IndexTarget(
+      IndexTarget Target(
 	    MetaKey,
 	    MetaKey,
 	    ShortDesc,
 	    ShortDesc,
 	    LongDesc,
 	    LongDesc,
@@ -225,13 +225,11 @@ struct ComputeIndexTargetsClass
 	    IsOptional,
 	    IsOptional,
 	    Options
 	    Options
 	    );
 	    );
-      IndexTargets->push_back(Target);
+      IndexTargets.push_back(Target);
    }
    }
-
-   ComputeIndexTargetsClass() : IndexTargets(new vector <IndexTarget *>) {}
 };
 };
 
 
-vector <IndexTarget *>* debReleaseIndex::ComputeIndexTargets() const
+std::vector<IndexTarget> debReleaseIndex::ComputeIndexTargets() const
 {
 {
    ComputeIndexTargetsClass comp;
    ComputeIndexTargetsClass comp;
    foreachTarget(URI, Dist, ArchEntries, comp);
    foreachTarget(URI, Dist, ArchEntries, comp);
@@ -249,7 +247,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
       iR->SetTrusted(false);
       iR->SetTrusted(false);
 
 
    // special case for --print-uris
    // special case for --print-uris
-   vector <IndexTarget *> const * const targets = ComputeIndexTargets();
+   std::vector<IndexTarget> const targets = ComputeIndexTargets();
 #define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, std::map<std::string,std::string>())
 #define APT_TARGET(X) IndexTarget("", X, MetaIndexInfo(X), MetaIndexURI(X), false, std::map<std::string,std::string>())
    pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
    pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
 	 APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
 	 APT_TARGET("InRelease"), APT_TARGET("Release"), APT_TARGET("Release.gpg"),
@@ -257,7 +255,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
 #undef APT_TARGET
 #undef APT_TARGET
    if (GetAll)
    if (GetAll)
    {
    {
-      for (vector <IndexTarget*>::const_iterator Target = targets->begin(); Target != targets->end(); ++Target)
+      for (std::vector<IndexTarget>::const_iterator Target = targets.begin(); Target != targets.end(); ++Target)
 	 new pkgAcqIndex(Owner, TransactionManager, *Target);
 	 new pkgAcqIndex(Owner, TransactionManager, *Target);
    }
    }
 
 

+ 1 - 1
apt-pkg/deb/debmetaindex.h

@@ -46,7 +46,7 @@ class APT_HIDDEN debReleaseIndex : public metaIndex {
 
 
    virtual std::string ArchiveURI(std::string const &File) const {return URI + File;};
    virtual std::string ArchiveURI(std::string const &File) const {return URI + File;};
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
    virtual bool GetIndexes(pkgAcquire *Owner, bool const &GetAll=false) const;
-   std::vector <IndexTarget *>* ComputeIndexTargets() const;
+   std::vector<IndexTarget> ComputeIndexTargets() const;
 
 
    std::string MetaIndexInfo(const char *Type) const;
    std::string MetaIndexInfo(const char *Type) const;
    std::string MetaIndexFile(const char *Types) const;
    std::string MetaIndexFile(const char *Types) const;