diff options
| author | Herman Semenoff <GermanAizek@yandex.ru> | 2026-04-08 12:58:55 +0300 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2026-04-08 10:41:43 +0000 |
| commit | 23dba65f031954df896bc3c6dfb1a9705574886b (patch) | |
| tree | 1f40f2afce10e3b793540e9905b624f113c2ee15 /apt-pkg/algorithms.cc | |
| parent | fbde7ea4ce304a30e155a2bd9d014d196abbb496 (diff) | |
apt: modernize to make_unique C++17
References:
- https://stackoverflow.com/questions/79700634/pros-and-cons-of-make-unique-vs-direct-constructor-call-in-c17
- https://towardsdev.com/why-std-make-unique-beats-new-in-modern-c-7e2ba653737e
- https://www.sololearn.com/en/Discuss/3334779/where-make_unique-is-better-than-unique_ptrraw-pointer
Diffstat (limited to 'apt-pkg/algorithms.cc')
| -rw-r--r-- | apt-pkg/algorithms.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index a08ecd2c6..44f186a82 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -554,7 +554,7 @@ void pkgProblemResolver::MakeScores() } // Copy the scores to advoid additive looping - std::unique_ptr<int[]> OldScores(new int[Size]); + auto OldScores = std::make_unique<int[]>(Size); memcpy(&OldScores[0],&Scores[0],sizeof(Scores[0])*Size); /* Now we cause 1 level of dependency inheritance, that is we add the @@ -797,7 +797,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) operates from highest score to lowest. This prevents problems when high score packages cause the removal of lower score packages that would cause the removal of even lower score packages. */ - std::unique_ptr<pkgCache::Package *[]> PList(new pkgCache::Package *[Size]); + auto PList = std::make_unique<pkgCache::Package *[]>(Size); pkgCache::Package **PEnd = &PList[0]; for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; @@ -1291,7 +1291,7 @@ bool pkgProblemResolver::ResolveByKeepInternal() high score packages cause the removal of lower score packages that would cause the removal of even lower score packages. */ auto Size = Cache.Head().PackageCount; - std::unique_ptr<pkgCache::Package *[]> PList{new pkgCache::Package *[Size]}; + auto PList = std::make_unique<pkgCache::Package *[]>(Size); pkgCache::Package **PEnd = &PList[0]; for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; |
