summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2019-06-14 15:50:39 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2019-06-14 15:52:41 +0200
commitd88af368d2a45bf9490fc629edbaa111da8a26cf (patch)
tree4cff941e4e701ffbfd0af86fd730f3961f03dbb0 /apt-pkg
parent6b6e942da072ef5b0f5d49b16c8bf2374f8a5071 (diff)
policy: Get rid of Pins array
Gbp-Dch: ignore
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/policy.cc30
-rw-r--r--apt-pkg/policy.h3
2 files changed, 13 insertions, 20 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index 1927553d4..b9bdfd20f 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -45,18 +45,14 @@ constexpr short NEVER_PIN = std::numeric_limits<short>::min();
// ---------------------------------------------------------------------
/* Set the defaults for operation. The default mode with no loaded policy
file matches the V0 policy engine. */
-pkgPolicy::pkgPolicy(pkgCache *Owner) : Pins(nullptr), VerPins(nullptr),
+pkgPolicy::pkgPolicy(pkgCache *Owner) : VerPins(nullptr),
PFPriority(nullptr), Cache(Owner), d(NULL)
{
if (Owner == 0)
return;
PFPriority = new signed short[Owner->Head().PackageFileCount];
- auto PackageCount = Owner->Head().PackageCount;
- Pins = new Pin[PackageCount];
VerPins = new Pin[Owner->Head().VersionCount];
- for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
- Pins[I].Type = pkgVersionMatch::None;
auto VersionCount = Owner->Head().VersionCount;
for (decltype(VersionCount) I = 0; I != VersionCount; ++I)
VerPins[I].Type = pkgVersionMatch::None;
@@ -217,24 +213,22 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
{
if (pams(Pkg.Arch()) == false)
continue;
- Pin *P = Pins + Pkg->ID;
- // the first specific stanza for a package is the ruler,
- // all others need to be ignored
- if (P->Type != pkgVersionMatch::None)
- P = &*Unmatched.insert(Unmatched.end(),PkgPin(Pkg.FullName()));
- P->Type = Type;
- P->Priority = Priority;
- P->Data = Data;
- matched = true;
+
+ PkgPin P(Pkg.FullName());
+ P.Type = Type;
+ P.Priority = Priority;
+ P.Data = Data;
// Find matching version(s) and copy the pin into it
- pkgVersionMatch Match(P->Data,P->Type);
+ pkgVersionMatch Match(P.Data,P.Type);
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver)
{
if (Match.VersionMatches(Ver)) {
Pin *VP = VerPins + Ver->ID;
- if (VP->Type == pkgVersionMatch::None)
- *VP = *P;
+ if (VP->Type == pkgVersionMatch::None) {
+ *VP = P;
+ matched = true;
+ }
}
}
}
@@ -420,4 +414,4 @@ bool ReadPinFile(pkgPolicy &Plcy,string File)
}
/*}}}*/
-pkgPolicy::~pkgPolicy() {delete [] PFPriority; delete [] Pins; delete [] VerPins; }
+pkgPolicy::~pkgPolicy() {delete [] PFPriority; delete [] VerPins; }
diff --git a/apt-pkg/policy.h b/apt-pkg/policy.h
index d3d68f921..277aff3dd 100644
--- a/apt-pkg/policy.h
+++ b/apt-pkg/policy.h
@@ -57,8 +57,7 @@ class pkgPolicy : public pkgDepCache::Policy
std::string Pkg;
explicit PkgPin(std::string const &Pkg) : Pin(), Pkg(Pkg) {};
};
-
- Pin *Pins;
+
Pin *VerPins;
signed short *PFPriority;
std::vector<Pin> Defaults;