summaryrefslogtreecommitdiff
path: root/apt-pkg/policy.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-01-13 19:29:06 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-02-14 19:45:12 +0100
commit18022c4a71ded214d69822d52804ce9344a9b65e (patch)
tree11e80c2db2f59a8a911fc16db4550813ca33e1f7 /apt-pkg/policy.cc
parent2666b0eb1cea31d92f89f1832f6efc5cc8a3f97f (diff)
policy: Use smart pointers
Diffstat (limited to 'apt-pkg/policy.cc')
-rw-r--r--apt-pkg/policy.cc15
1 files changed, 5 insertions, 10 deletions
diff --git a/apt-pkg/policy.cc b/apt-pkg/policy.cc
index a54f04db6..ab21cd039 100644
--- a/apt-pkg/policy.cc
+++ b/apt-pkg/policy.cc
@@ -57,8 +57,8 @@ pkgPolicy::pkgPolicy(pkgCache *Owner) : VerPins(nullptr),
{
if (Owner == 0)
return;
- PFPriority = new signed short[Owner->Head().PackageFileCount];
- VerPins = new Pin[Owner->Head().VersionCount];
+ PFPriority = std::make_unique<signed short[]>(Owner->Head().PackageFileCount);
+ VerPins = std::make_unique<Pin[]>(Owner->Head().VersionCount);
auto VersionCount = Owner->Head().VersionCount;
for (decltype(VersionCount) I = 0; I != VersionCount; ++I)
@@ -237,7 +237,7 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
// Find matching version(s) and copy the pin into it
pkgVersionMatch Match(P.Data,P.Type);
if (Match.VersionMatches(Ver)) {
- Pin *VP = VerPins + Ver->ID;
+ Pin *VP = &VerPins[Ver->ID];
if (VP->Type == pkgVersionMatch::None) {
*VP = P;
matched = true;
@@ -260,7 +260,7 @@ void pkgPolicy::CreatePin(pkgVersionMatch::MatchType Type,string Name,
for (pkgCache::VerIterator Ver = Pkg.VersionList(); Ver.end() != true; ++Ver)
{
if (Match.VersionMatches(Ver)) {
- Pin *VP = VerPins + Ver->ID;
+ Pin *VP = &VerPins[Ver->ID];
if (VP->Type == pkgVersionMatch::None) {
*VP = P;
matched = true;
@@ -503,9 +503,4 @@ bool ReadPinFile(pkgPolicy &Plcy,string File)
}
/*}}}*/
-pkgPolicy::~pkgPolicy()
-{
- delete[] PFPriority;
- delete[] VerPins;
- delete d;
-}
+pkgPolicy::~pkgPolicy() = default;