From d88af368d2a45bf9490fc629edbaa111da8a26cf Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Fri, 14 Jun 2019 15:50:39 +0200 Subject: policy: Get rid of Pins array Gbp-Dch: ignore --- apt-pkg/policy.cc | 30 ++++++++++++------------------ apt-pkg/policy.h | 3 +-- 2 files changed, 13 insertions(+), 20 deletions(-) (limited to 'apt-pkg') 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::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 Defaults; -- cgit v1.2.3