diff options
| author | louist103 <35883445+louist103@users.noreply.github.com> | 2021-04-24 16:42:52 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-04-24 16:42:52 -0400 |
| commit | 6d27dbaab3b32ccebb076895fac3cc6aa3240d6c (patch) | |
| tree | 601c6ab5bef2f93b6d6ef4ba5506eb04dfb59c9f /ZAPD/ZVector.cpp | |
| parent | ee8bdea252db4c764f4a2567c32754118fdce10b (diff) | |
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
Diffstat (limited to 'ZAPD/ZVector.cpp')
| -rw-r--r-- | ZAPD/ZVector.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
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<uint8_t>& 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<std::string> strings = std::vector<std::string>(); - 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, ", ") + " }"; |
