summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-10 22:10:48 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-06-10 22:10:48 +0200
commitdcbbb14df8c9a8a146697720874e9425c4b33792 (patch)
treee58428a794598e0819ec7cd381fca9b90331c1e9 /apt-pkg/deb
parentd3a869e35503638e3483228fbfc95b7143568ad0 (diff)
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
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/debmetaindex.cc16
-rw-r--r--apt-pkg/deb/debmetaindex.h2
2 files changed, 8 insertions, 10 deletions
diff --git a/apt-pkg/deb/debmetaindex.cc b/apt-pkg/deb/debmetaindex.cc
index f038f12f5..44d66a725 100644
--- a/apt-pkg/deb/debmetaindex.cc
+++ b/apt-pkg/deb/debmetaindex.cc
@@ -93,7 +93,7 @@ debReleaseIndex::~debReleaseIndex() {
template<typename CallC>
void foreachTarget(std::string const URI, std::string const Dist,
std::map<std::string, std::vector<debReleaseIndex::debSectionEntry const *> > const &ArchEntries,
- CallC Call)
+ CallC &Call)
{
bool const flatArchive = (Dist[Dist.length() - 1] == '/');
std::string baseURI = URI;
@@ -206,7 +206,7 @@ void foreachTarget(std::string const URI, std::string const Dist,
struct ComputeIndexTargetsClass
{
- vector <IndexTarget *> * const IndexTargets;
+ vector <IndexTarget> IndexTargets;
void operator()(std::string MetaKey, std::string ShortDesc, std::string LongDesc,
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);
LongDesc = SubstVar(LongDesc, std::string("$(") + O->first + ")", O->second);
}
- IndexTarget * Target = new IndexTarget(
+ IndexTarget Target(
MetaKey,
ShortDesc,
LongDesc,
@@ -225,13 +225,11 @@ struct ComputeIndexTargetsClass
IsOptional,
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;
foreachTarget(URI, Dist, ArchEntries, comp);
@@ -249,7 +247,7 @@ bool debReleaseIndex::GetIndexes(pkgAcquire *Owner, bool const &GetAll) const
iR->SetTrusted(false);
// 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>())
pkgAcqMetaBase * const TransactionManager = new pkgAcqMetaClearSig(Owner,
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
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);
}
diff --git a/apt-pkg/deb/debmetaindex.h b/apt-pkg/deb/debmetaindex.h
index e1c1d91ef..4e630cf5d 100644
--- a/apt-pkg/deb/debmetaindex.h
+++ b/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 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 MetaIndexFile(const char *Types) const;