summaryrefslogtreecommitdiff
path: root/cmdline
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2017-06-04 18:14:13 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2017-06-26 23:31:15 +0200
commitfc2055e1e08e4e3b662b0c5f67a0d0a57267acd3 (patch)
treebf071ffd9f1beb27847ec62d7186e7f2902cad41 /cmdline
parentd0eb158be03f15139eee65c4162c9c6e3be10718 (diff)
avoid explicit types for pkg counts by auto
Changes nothing on the program front and as the datatypes are sufficently comparable fixes no bug either, but problems later on if we ever change the types of those and prevent us using types which are too large for the values we want to store waste (a tiny bit of) resources. Gbp-Dch: Ignore
Diffstat (limited to 'cmdline')
-rw-r--r--cmdline/apt-cache.cc28
1 files changed, 15 insertions, 13 deletions
diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 0d7425c48..2fe2e7649 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -404,7 +404,7 @@ static bool DumpAvail(CommandLine &)
if (unlikely(Cache == NULL || CacheFile.BuildPolicy() == false))
return false;
- unsigned long Count = Cache->HeaderP->PackageCount+1;
+ auto const Count = Cache->HeaderP->PackageCount+1;
pkgCache::VerFile **VFList = new pkgCache::VerFile *[Count];
memset(VFList,0,sizeof(*VFList)*Count);
@@ -565,18 +565,19 @@ static bool XVcg(CommandLine &CmdL)
0 = None */
enum States {None=0, ToShow, ToShowNR, DoneNR, Done};
enum TheFlags {ForceNR=(1<<0)};
- unsigned char *Show = new unsigned char[Cache->Head().PackageCount];
- unsigned char *Flags = new unsigned char[Cache->Head().PackageCount];
- unsigned char *ShapeMap = new unsigned char[Cache->Head().PackageCount];
+ auto PackageCount = Cache->Head().PackageCount;
+ unsigned char *Show = new unsigned char[PackageCount];
+ unsigned char *Flags = new unsigned char[PackageCount];
+ unsigned char *ShapeMap = new unsigned char[PackageCount];
// Show everything if no arguments given
if (CmdL.FileList[1] == 0)
- for (unsigned long I = 0; I != Cache->Head().PackageCount; I++)
+ for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
Show[I] = ToShow;
else
- for (unsigned long I = 0; I != Cache->Head().PackageCount; I++)
+ for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
Show[I] = None;
- memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount);
+ memset(Flags,0,sizeof(*Flags)*PackageCount);
// Map the shapes
for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
@@ -777,18 +778,19 @@ static bool Dotty(CommandLine &CmdL)
0 = None */
enum States {None=0, ToShow, ToShowNR, DoneNR, Done};
enum TheFlags {ForceNR=(1<<0)};
- unsigned char *Show = new unsigned char[Cache->Head().PackageCount];
- unsigned char *Flags = new unsigned char[Cache->Head().PackageCount];
- unsigned char *ShapeMap = new unsigned char[Cache->Head().PackageCount];
+ auto PackageCount = Cache->Head().PackageCount;
+ unsigned char *Show = new unsigned char[PackageCount];
+ unsigned char *Flags = new unsigned char[PackageCount];
+ unsigned char *ShapeMap = new unsigned char[PackageCount];
// Show everything if no arguments given
if (CmdL.FileList[1] == 0)
- for (unsigned long I = 0; I != Cache->Head().PackageCount; I++)
+ for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
Show[I] = ToShow;
else
- for (unsigned long I = 0; I != Cache->Head().PackageCount; I++)
+ for (decltype(PackageCount) I = 0; I != PackageCount; ++I)
Show[I] = None;
- memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount);
+ memset(Flags,0,sizeof(*Flags)*PackageCount);
// Map the shapes
for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)