diff options
Diffstat (limited to 'apt-pkg/algorithms.cc')
-rw-r--r-- | apt-pkg/algorithms.cc | 42 |
1 files changed, 13 insertions, 29 deletions
diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index adbec82f7..6d982c551 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -19,9 +19,7 @@ #include <apt-pkg/algorithms.h> #include <apt-pkg/error.h> #include <apt-pkg/configuration.h> -#include <apt-pkg/sptr.h> #include <apt-pkg/edsp.h> -#include <apt-pkg/progress.h> #include <apt-pkg/depcache.h> #include <apt-pkg/packagemanager.h> #include <apt-pkg/pkgcache.h> @@ -43,7 +41,7 @@ pkgProblemResolver *pkgProblemResolver::This = 0; /* The legacy translations here of input Pkg iterators is obsolete, this is not necessary since the pkgCaches are fully shared now. */ pkgSimulate::pkgSimulate(pkgDepCache *Cache) : pkgPackageManager(Cache), - iPolicy(Cache), + d(NULL), iPolicy(Cache), Sim(&Cache->GetCache(),&iPolicy), group(Sim) { @@ -476,8 +474,8 @@ void pkgProblemResolver::MakeScores() } // Copy the scores to advoid additive looping - SPtrArray<int> OldScores = new int[Size]; - memcpy(OldScores,Scores,sizeof(*Scores)*Size); + std::unique_ptr<int[]> OldScores(new int[Size]); + memcpy(OldScores.get(),Scores,sizeof(*Scores)*Size); /* Now we cause 1 level of dependency inheritance, that is we add the score of the packages that depend on the target Package. This @@ -638,14 +636,6 @@ bool pkgProblemResolver::DoUpgrade(pkgCache::PkgIterator Pkg) } /*}}}*/ // ProblemResolver::Resolve - calls a resolver to fix the situation /*{{{*/ -// --------------------------------------------------------------------- -/* */ -#if APT_PKG_ABI < 413 -bool pkgProblemResolver::Resolve(bool BrokenFix) -{ - return Resolve(BrokenFix, NULL); -} -#endif bool pkgProblemResolver::Resolve(bool BrokenFix, OpProgress * const Progress) { std::string const solver = _config->Find("APT::Solver", "internal"); @@ -710,17 +700,17 @@ 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. */ - SPtrArray<pkgCache::Package *> PList = new pkgCache::Package *[Size]; - pkgCache::Package **PEnd = PList; + std::unique_ptr<pkgCache::Package *[]> PList(new pkgCache::Package *[Size]); + pkgCache::Package **PEnd = PList.get(); for (pkgCache::PkgIterator I = Cache.PkgBegin(); I.end() == false; ++I) *PEnd++ = I; This = this; - qsort(PList,PEnd - PList,sizeof(*PList),&ScoreSort); + qsort(PList.get(),PEnd - PList.get(),sizeof(PList[0]),&ScoreSort); if (_config->FindB("Debug::pkgProblemResolver::ShowScores",false) == true) { clog << "Show Scores" << endl; - for (pkgCache::Package **K = PList; K != PEnd; K++) + for (pkgCache::Package **K = PList.get(); K != PEnd; K++) if (Scores[(*K)->ID] != 0) { pkgCache::PkgIterator Pkg(Cache,*K); @@ -742,7 +732,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) for (int Counter = 0; Counter != 10 && Change == true; Counter++) { Change = false; - for (pkgCache::Package **K = PList; K != PEnd; K++) + for (pkgCache::Package **K = PList.get(); K != PEnd; K++) { pkgCache::PkgIterator I(Cache,*K); @@ -853,8 +843,8 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) /* Look across the version list. If there are no possible targets then we keep the package and bail. This is necessary if a package has a dep on another package that can't be found */ - SPtrArray<pkgCache::Version *> VList = Start.AllTargets(); - if (*VList == 0 && (Flags[I->ID] & Protected) != Protected && + std::unique_ptr<pkgCache::Version *[]> VList(Start.AllTargets()); + if (VList[0] == 0 && (Flags[I->ID] & Protected) != Protected && Start.IsNegative() == false && Cache[I].NowBroken() == false) { @@ -871,7 +861,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) } bool Done = false; - for (pkgCache::Version **V = VList; *V != 0; V++) + for (pkgCache::Version **V = VList.get(); *V != 0; V++) { pkgCache::VerIterator Ver(Cache,*V); pkgCache::PkgIterator Pkg = Ver.ParentPkg(); @@ -1144,12 +1134,6 @@ bool pkgProblemResolver::InstOrNewPolicyBroken(pkgCache::PkgIterator I) /* This is the work horse of the soft upgrade routine. It is very gental in that it does not install or remove any packages. It is assumed that the system was non-broken previously. */ -#if APT_PKG_ABI < 413 -bool pkgProblemResolver::ResolveByKeep() -{ - return ResolveByKeep(NULL); -} -#endif bool pkgProblemResolver::ResolveByKeep(OpProgress * const Progress) { std::string const solver = _config->Find("APT::Solver", "internal"); @@ -1247,8 +1231,8 @@ bool pkgProblemResolver::ResolveByKeepInternal() clog << "Package " << I.FullName(false) << " " << Start << endl; // Look at all the possible provides on this package - SPtrArray<pkgCache::Version *> VList = Start.AllTargets(); - for (pkgCache::Version **V = VList; *V != 0; V++) + std::unique_ptr<pkgCache::Version *[]> VList(Start.AllTargets()); + for (pkgCache::Version **V = VList.get(); *V != 0; V++) { pkgCache::VerIterator Ver(Cache,*V); pkgCache::PkgIterator Pkg = Ver.ParentPkg(); |