From 23dba65f031954df896bc3c6dfb1a9705574886b Mon Sep 17 00:00:00 2001 From: Herman Semenoff Date: Wed, 8 Apr 2026 12:58:55 +0300 Subject: 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 --- apt-pkg/algorithms.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'apt-pkg/algorithms.cc') 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 OldScores(new int[Size]); + auto OldScores = std::make_unique(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 PList(new pkgCache::Package *[Size]); + auto PList = std::make_unique(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 PList{new pkgCache::Package *[Size]}; + auto PList = std::make_unique(Size); pkgCache::Package **PEnd = &PList[0]; for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; -- cgit v1.2.3-70-g09d2