From 6d27dbaab3b32ccebb076895fac3cc6aa3240d6c Mon Sep 17 00:00:00 2001 From: louist103 <35883445+louist103@users.noreply.github.com> Date: Sat, 24 Apr 2021 16:42:52 -0400 Subject: Fix most -Wall warnings (#115) * started on basic type errors * Done. For now * remove libgfxd binary * Most warnings fixed * Fix conflicts and new warnings * Makefile * Sig * Clang format * destructor * Add a bunch of destructors * clear the scalars vector after freeing the elements * PR fixes (Anghelo Alf) * Fix most clang -Wall warnings --- ZAPD/ZVector.cpp | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'ZAPD/ZVector.cpp') diff --git a/ZAPD/ZVector.cpp b/ZAPD/ZVector.cpp index 98dc3f2..2a732bc 100644 --- a/ZAPD/ZVector.cpp +++ b/ZAPD/ZVector.cpp @@ -15,8 +15,21 @@ ZVector::ZVector(ZFile* nParent) : ZResource(nParent) this->dimensions = 0; } +ZVector::~ZVector() +{ + ClearScalars(); +} + +void ZVector::ClearScalars() +{ + for(auto s: scalars) + delete s; + + scalars.clear(); +} + void ZVector::ExtractFromXML(tinyxml2::XMLElement* reader, const std::vector& nRawData, - const int nRawDataIndex, const std::string& nRelPath) + const uint32_t nRawDataIndex, const std::string& nRelPath) { ZResource::ExtractFromXML(reader, nRawData, nRawDataIndex, nRelPath); } @@ -34,9 +47,9 @@ void ZVector::ParseXML(tinyxml2::XMLElement* reader) void ZVector::ParseRawData() { - int currentRawDataIndex = this->rawDataIndex; + int32_t currentRawDataIndex = this->rawDataIndex; - scalars.clear(); + ClearScalars(); for (uint32_t i = 0; i < this->dimensions; i++) { @@ -53,11 +66,11 @@ void ZVector::ParseRawData() assert(this->scalars.size() == this->dimensions); } -int ZVector::GetRawDataSize() +size_t ZVector::GetRawDataSize() { - int size = 0; + size_t size = 0; - for (int i = 0; i < this->scalars.size(); i++) + for (size_t i = 0; i < this->scalars.size(); i++) size += this->scalars[i]->GetRawDataSize(); return size; @@ -93,7 +106,7 @@ std::string ZVector::GetSourceValue() { std::vector strings = std::vector(); - for (int i = 0; i < this->scalars.size(); i++) + for (size_t i = 0; i < this->scalars.size(); i++) strings.push_back(scalars[i]->GetSourceValue()); return "{ " + StringHelper::Implode(strings, ", ") + " }"; -- cgit v1.2.3