Skip to content

Commit

Permalink
Merge pull request #911 from JurajX/fix_warnings
Browse files Browse the repository at this point in the history
Fix warnings
  • Loading branch information
leethomason authored Nov 21, 2023
2 parents e059560 + 8fd6cc6 commit 5203571
Showing 1 changed file with 52 additions and 52 deletions.
104 changes: 52 additions & 52 deletions tinyxml2.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,9 @@ class DynArray
if ( cap > _allocated ) {
TIXMLASSERT( cap <= INT_MAX / 2 );
const int newAllocated = cap * 2;
T* newMem = new T[newAllocated];
T* newMem = new T[static_cast<unsigned int>(newAllocated)];
TIXMLASSERT( newAllocated >= _size );
memcpy( newMem, _mem, sizeof(T)*_size ); // warning: not using constructors, only works for PODs
memcpy( newMem, _mem, sizeof(T)*static_cast<size_t>(_size) ); // warning: not using constructors, only works for PODs
if ( _mem != _pool ) {
delete [] _mem;
}
Expand All @@ -317,7 +317,7 @@ class DynArray
}

T* _mem;
T _pool[INITIAL_SIZE];
T _pool[static_cast<size_t>(INITIAL_SIZE)];
int _allocated; // objects allocated
int _size; // number objects in use
};
Expand Down Expand Up @@ -365,14 +365,14 @@ class MemPoolT : public MemPool
_nUntracked = 0;
}

virtual int ItemSize() const {
virtual int ItemSize() const override{
return ITEM_SIZE;
}
int CurrentAllocs() const {
return _currentAllocs;
}

virtual void* Alloc() {
virtual void* Alloc() override{
if ( !_root ) {
// Need a new block.
Block* block = new Block;
Expand All @@ -398,7 +398,7 @@ class MemPoolT : public MemPool
return result;
}

virtual void Free( void* mem ) {
virtual void Free( void* mem ) override {
if ( !mem ) {
return;
}
Expand All @@ -416,7 +416,7 @@ class MemPoolT : public MemPool
ITEM_SIZE, _nAllocs, _blockPtrs.Size() );
}

void SetTracked() {
void SetTracked() override {
--_nUntracked;
}

Expand All @@ -443,7 +443,7 @@ class MemPoolT : public MemPool

union Item {
Item* next;
char itemData[ITEM_SIZE];
char itemData[static_cast<size_t>(ITEM_SIZE)];
};
struct Block {
Item items[ITEMS_PER_BLOCK];
Expand Down Expand Up @@ -603,7 +603,7 @@ class TINYXML2_LIB XMLUtil
TIXMLASSERT( p );
TIXMLASSERT( q );
TIXMLASSERT( nChar >= 0 );
return strncmp( p, q, nChar ) == 0;
return strncmp( p, q, static_cast<size_t>(nChar) ) == 0;
}

inline static bool IsUTF8Continuation( const char p ) {
Expand Down Expand Up @@ -992,12 +992,12 @@ class TINYXML2_LIB XMLText : public XMLNode
{
friend class XMLDocument;
public:
virtual bool Accept( XMLVisitor* visitor ) const;
virtual bool Accept( XMLVisitor* visitor ) const override;

virtual XMLText* ToText() {
virtual XMLText* ToText() override {
return this;
}
virtual const XMLText* ToText() const {
virtual const XMLText* ToText() const override {
return this;
}

Expand All @@ -1010,14 +1010,14 @@ class TINYXML2_LIB XMLText : public XMLNode
return _isCData;
}

virtual XMLNode* ShallowClone( XMLDocument* document ) const;
virtual bool ShallowEqual( const XMLNode* compare ) const;
virtual XMLNode* ShallowClone( XMLDocument* document ) const override;
virtual bool ShallowEqual( const XMLNode* compare ) const override;

protected:
explicit XMLText( XMLDocument* doc ) : XMLNode( doc ), _isCData( false ) {}
virtual ~XMLText() {}

char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override;

private:
bool _isCData;
Expand All @@ -1032,23 +1032,23 @@ class TINYXML2_LIB XMLComment : public XMLNode
{
friend class XMLDocument;
public:
virtual XMLComment* ToComment() {
virtual XMLComment* ToComment() override {
return this;
}
virtual const XMLComment* ToComment() const {
virtual const XMLComment* ToComment() const override {
return this;
}

virtual bool Accept( XMLVisitor* visitor ) const;
virtual bool Accept( XMLVisitor* visitor ) const override;

virtual XMLNode* ShallowClone( XMLDocument* document ) const;
virtual bool ShallowEqual( const XMLNode* compare ) const;
virtual XMLNode* ShallowClone( XMLDocument* document ) const override;
virtual bool ShallowEqual( const XMLNode* compare ) const override;

protected:
explicit XMLComment( XMLDocument* doc );
virtual ~XMLComment();

char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr);
char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr) override;

private:
XMLComment( const XMLComment& ); // not supported
Expand All @@ -1071,23 +1071,23 @@ class TINYXML2_LIB XMLDeclaration : public XMLNode
{
friend class XMLDocument;
public:
virtual XMLDeclaration* ToDeclaration() {
virtual XMLDeclaration* ToDeclaration() override {
return this;
}
virtual const XMLDeclaration* ToDeclaration() const {
virtual const XMLDeclaration* ToDeclaration() const override {
return this;
}

virtual bool Accept( XMLVisitor* visitor ) const;
virtual bool Accept( XMLVisitor* visitor ) const override;

virtual XMLNode* ShallowClone( XMLDocument* document ) const;
virtual bool ShallowEqual( const XMLNode* compare ) const;
virtual XMLNode* ShallowClone( XMLDocument* document ) const override;
virtual bool ShallowEqual( const XMLNode* compare ) const override;

protected:
explicit XMLDeclaration( XMLDocument* doc );
virtual ~XMLDeclaration();

char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override;

private:
XMLDeclaration( const XMLDeclaration& ); // not supported
Expand All @@ -1106,23 +1106,23 @@ class TINYXML2_LIB XMLUnknown : public XMLNode
{
friend class XMLDocument;
public:
virtual XMLUnknown* ToUnknown() {
virtual XMLUnknown* ToUnknown() override {
return this;
}
virtual const XMLUnknown* ToUnknown() const {
virtual const XMLUnknown* ToUnknown() const override {
return this;
}

virtual bool Accept( XMLVisitor* visitor ) const;
virtual bool Accept( XMLVisitor* visitor ) const override;

virtual XMLNode* ShallowClone( XMLDocument* document ) const;
virtual bool ShallowEqual( const XMLNode* compare ) const;
virtual XMLNode* ShallowClone( XMLDocument* document ) const override;
virtual bool ShallowEqual( const XMLNode* compare ) const override;

protected:
explicit XMLUnknown( XMLDocument* doc );
virtual ~XMLUnknown();

char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override;

private:
XMLUnknown( const XMLUnknown& ); // not supported
Expand Down Expand Up @@ -1274,13 +1274,13 @@ class TINYXML2_LIB XMLElement : public XMLNode
SetValue( str, staticMem );
}

virtual XMLElement* ToElement() {
virtual XMLElement* ToElement() override {
return this;
}
virtual const XMLElement* ToElement() const {
virtual const XMLElement* ToElement() const override {
return this;
}
virtual bool Accept( XMLVisitor* visitor ) const;
virtual bool Accept( XMLVisitor* visitor ) const override;

/** Given an attribute name, Attribute() returns the value
for the attribute of that name, or null if none
Expand Down Expand Up @@ -1676,11 +1676,11 @@ class TINYXML2_LIB XMLElement : public XMLNode
ElementClosingType ClosingType() const {
return _closingType;
}
virtual XMLNode* ShallowClone( XMLDocument* document ) const;
virtual bool ShallowEqual( const XMLNode* compare ) const;
virtual XMLNode* ShallowClone( XMLDocument* document ) const override;
virtual bool ShallowEqual( const XMLNode* compare ) const override;

protected:
char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr );
char* ParseDeep( char* p, StrPair* parentEndTag, int* curLineNumPtr ) override;

private:
XMLElement( XMLDocument* doc );
Expand Down Expand Up @@ -1728,11 +1728,11 @@ class TINYXML2_LIB XMLDocument : public XMLNode
XMLDocument( bool processEntities = true, Whitespace whitespaceMode = PRESERVE_WHITESPACE );
~XMLDocument();

virtual XMLDocument* ToDocument() {
virtual XMLDocument* ToDocument() override {
TIXMLASSERT( this == _document );
return this;
}
virtual const XMLDocument* ToDocument() const {
virtual const XMLDocument* ToDocument() const override {
TIXMLASSERT( this == _document );
return this;
}
Expand Down Expand Up @@ -1829,7 +1829,7 @@ class TINYXML2_LIB XMLDocument : public XMLNode
@endverbatim
*/
void Print( XMLPrinter* streamer=0 ) const;
virtual bool Accept( XMLVisitor* visitor ) const;
virtual bool Accept( XMLVisitor* visitor ) const override;

/**
Create a new Element associated with
Expand Down Expand Up @@ -1920,10 +1920,10 @@ class TINYXML2_LIB XMLDocument : public XMLNode
// internal
void MarkInUse(const XMLNode* const);

virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const {
virtual XMLNode* ShallowClone( XMLDocument* /*document*/ ) const override{
return 0;
}
virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const {
virtual bool ShallowEqual( const XMLNode* /*compare*/ ) const override{
return false;
}

Expand Down Expand Up @@ -2286,18 +2286,18 @@ class TINYXML2_LIB XMLPrinter : public XMLVisitor
void PushDeclaration( const char* value );
void PushUnknown( const char* value );

virtual bool VisitEnter( const XMLDocument& /*doc*/ );
virtual bool VisitExit( const XMLDocument& /*doc*/ ) {
virtual bool VisitEnter( const XMLDocument& /*doc*/ ) override;
virtual bool VisitExit( const XMLDocument& /*doc*/ ) override {
return true;
}

virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute );
virtual bool VisitExit( const XMLElement& element );
virtual bool VisitEnter( const XMLElement& element, const XMLAttribute* attribute ) override;
virtual bool VisitExit( const XMLElement& element ) override;

virtual bool Visit( const XMLText& text );
virtual bool Visit( const XMLComment& comment );
virtual bool Visit( const XMLDeclaration& declaration );
virtual bool Visit( const XMLUnknown& unknown );
virtual bool Visit( const XMLText& text ) override;
virtual bool Visit( const XMLComment& comment ) override;
virtual bool Visit( const XMLDeclaration& declaration ) override;
virtual bool Visit( const XMLUnknown& unknown ) override;

/**
If in print to memory mode, return a pointer to
Expand Down

0 comments on commit 5203571

Please sign in to comment.