summaryrefslogtreecommitdiff
path: root/apt-pkg/contrib/hashes.cc
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2015-06-17 09:29:00 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2015-08-10 17:25:25 +0200
commit6c55f07a5fa3612a5d59c61a17da5fe640eadc8b (patch)
treee63587b9caf9781cb4606e0a95b4f19d7b727f92 /apt-pkg/contrib/hashes.cc
parente8afd16892e87a6e2f17c1019ee455f5583387c2 (diff)
make all d-pointer * const pointers
Doing this disables the implicit copy assignment operator (among others) which would cause hovac if used on the classes as it would just copy the pointer, not the data the d-pointer points to. For most of the classes we don't need a copy assignment operator anyway and in many classes it was broken before as many contain a pointer of some sort. Only for our Cacheset Container interfaces we define an explicit copy assignment operator which could later be implemented to copy the data from one d-pointer to the other if we need it. Git-Dch: Ignore
Diffstat (limited to 'apt-pkg/contrib/hashes.cc')
-rw-r--r--apt-pkg/contrib/hashes.cc29
1 files changed, 15 insertions, 14 deletions
diff --git a/apt-pkg/contrib/hashes.cc b/apt-pkg/contrib/hashes.cc
index 05a137653..4481321c4 100644
--- a/apt-pkg/contrib/hashes.cc
+++ b/apt-pkg/contrib/hashes.cc
@@ -277,6 +277,18 @@ public:
unsigned int CalcHashes;
explicit PrivateHashes(unsigned int const CalcHashes) : FileSize(0), CalcHashes(CalcHashes) {}
+ explicit PrivateHashes(HashStringList const &Hashes) : FileSize(0) {
+ unsigned int calcHashes = Hashes.usable() ? 0 : ~0;
+ if (Hashes.find("MD5Sum") != NULL)
+ calcHashes |= Hashes::MD5SUM;
+ if (Hashes.find("SHA1") != NULL)
+ calcHashes |= Hashes::SHA1SUM;
+ if (Hashes.find("SHA256") != NULL)
+ calcHashes |= Hashes::SHA256SUM;
+ if (Hashes.find("SHA512") != NULL)
+ calcHashes |= Hashes::SHA512SUM;
+ CalcHashes = calcHashes;
+ }
};
/*}}}*/
// Hashes::Add* - Add the contents of data or FD /*{{{*/
@@ -372,19 +384,8 @@ APT_IGNORE_DEPRECATED_POP
return hashes;
}
APT_IGNORE_DEPRECATED_PUSH
-Hashes::Hashes() { d = new PrivateHashes(~0); }
-Hashes::Hashes(unsigned int const Hashes) { d = new PrivateHashes(Hashes); }
-Hashes::Hashes(HashStringList const &Hashes) {
- unsigned int calcHashes = Hashes.usable() ? 0 : ~0;
- if (Hashes.find("MD5Sum") != NULL)
- calcHashes |= MD5SUM;
- if (Hashes.find("SHA1") != NULL)
- calcHashes |= SHA1SUM;
- if (Hashes.find("SHA256") != NULL)
- calcHashes |= SHA256SUM;
- if (Hashes.find("SHA512") != NULL)
- calcHashes |= SHA512SUM;
- d = new PrivateHashes(calcHashes);
-}
+Hashes::Hashes() : d(new PrivateHashes(~0)) { }
+Hashes::Hashes(unsigned int const Hashes) : d(new PrivateHashes(Hashes)) {}
+Hashes::Hashes(HashStringList const &Hashes) : d(new PrivateHashes(Hashes)) {}
Hashes::~Hashes() { delete d; }
APT_IGNORE_DEPRECATED_POP