From b6662b61dd83be32481a1c83e092082e9d797f0a Mon Sep 17 00:00:00 2001 From: Dimitri van Heesch Date: Wed, 26 Dec 2018 09:49:26 +0100 Subject: Fixed some more small memory leaks --- qtools/qlist.h | 1 + src/doxygen.cpp | 5 ++++- src/entry.cpp | 2 +- src/marshal.cpp | 17 ++++++++++++----- src/pycode.l | 6 ++++-- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/qtools/qlist.h b/qtools/qlist.h index e9b908d..eaaa674 100644 --- a/qtools/qlist.h +++ b/qtools/qlist.h @@ -97,6 +97,7 @@ public: // ownership void setAutoDelete( bool enable ) { QGList::setAutoDelete(enable); } + bool autoDelete() const { return QGList::autoDelete(); } private: // new to be reimplemented methods diff --git a/src/doxygen.cpp b/src/doxygen.cpp index e8df763..2d55ae6 100644 --- a/src/doxygen.cpp +++ b/src/doxygen.cpp @@ -9937,7 +9937,6 @@ void readFormulaRepository(QCString dir, bool cmp) else { f=new Formula(formText); - Doxygen::formulaList->setAutoDelete(TRUE); Doxygen::formulaList->append(f); Doxygen::formulaDict->insert(formText,f); Doxygen::formulaNameDict->insert(formName,f); @@ -10231,6 +10230,7 @@ void initDoxygen() Doxygen::genericsDict = new GenericsSDict; Doxygen::indexList = new IndexList; Doxygen::formulaList = new FormulaList; + Doxygen::formulaList->setAutoDelete(TRUE); Doxygen::formulaDict = new FormulaDict(1009); Doxygen::formulaNameDict = new FormulaDict(1009); Doxygen::sectionDict = new SectionDict(257); @@ -10729,8 +10729,11 @@ void adjustConfiguration() Doxygen::imageNameDict = new FileNameDict(257); Doxygen::imageNameDict->setAutoDelete(TRUE); Doxygen::dotFileNameDict = new FileNameDict(257); + Doxygen::dotFileNameDict->setAutoDelete(TRUE); Doxygen::mscFileNameDict = new FileNameDict(257); + Doxygen::mscFileNameDict->setAutoDelete(TRUE); Doxygen::diaFileNameDict = new FileNameDict(257); + Doxygen::diaFileNameDict->setAutoDelete(TRUE); QCString outputLanguage=Config_getEnum(OUTPUT_LANGUAGE); if (!setTranslator(outputLanguage)) diff --git a/src/entry.cpp b/src/entry.cpp index 15c6fec..b3693cd 100644 --- a/src/entry.cpp +++ b/src/entry.cpp @@ -170,7 +170,7 @@ Entry::Entry(const Entry &e) SectionInfo *s; for (;(s=sli2.current());++sli2) { - anchors->append(new SectionInfo(*s)); + anchors->append(s); // shallow copy, object are owned by Doxygen::sectionDict } // deep copy type constraint list diff --git a/src/marshal.cpp b/src/marshal.cpp index 57ff44b..1c7d54e 100644 --- a/src/marshal.cpp +++ b/src/marshal.cpp @@ -10,6 +10,7 @@ #include "groupdef.h" #include "example.h" #include "arguments.h" +#include "doxygen.h" #define HEADER ('D'<<24)+('O'<<16)+('X'<<8)+'!' @@ -141,7 +142,9 @@ void marshalSectionInfoList(StorageIntf *s, QList *anchors) marshalQCString(s,si->fileName); marshalInt(s,si->lineNr); marshalInt(s,si->level); + delete Doxygen::sectionDict->take(si->label); // this dict owns the anchor objects } + anchors->clear(); } } @@ -550,11 +553,10 @@ QList *unmarshalSectionInfoList(StorageIntf *s) uint i; uint count = unmarshalUInt(s); if (count==NULL_LIST) return 0; // null list - QList *result = new QList; - result->setAutoDelete(TRUE); + QList *anchors = new QList; assert(count<1000000); for (i=0;i *unmarshalSectionInfoList(StorageIntf *s) QCString fileName = unmarshalQCString(s); int lineNr = unmarshalInt(s); int level = unmarshalInt(s); - result->append(new SectionInfo(fileName,lineNr,label,title,type,level,ref)); + if (Doxygen::sectionDict->find(label)==0) + { + SectionInfo *si = new SectionInfo(fileName,lineNr,label,title,type,level,ref); + anchors->append(si); + Doxygen::sectionDict->append(label,si); // this dict owns the anchor objects + } } - return result; + return anchors; } QList *unmarshalItemInfoList(StorageIntf *s) diff --git a/src/pycode.l b/src/pycode.l index dfa383f..d9c9f01 100644 --- a/src/pycode.l +++ b/src/pycode.l @@ -1091,8 +1091,7 @@ TARGET ({IDENTIFIER}|"("{TARGET_LIST}")"|"["{TARGET_LIST}"]"|{ATTRIBUT char *s=g_curClassBases.first(); while (s) { - ClassDef *baseDefToAdd; - baseDefToAdd=g_codeClassSDict[s]; + ClassDef *baseDefToAdd=g_codeClassSDict[s]; // Try to find class in global // scope @@ -1517,6 +1516,8 @@ TARGET ({IDENTIFIER}|"("{TARGET_LIST}")"|"["{TARGET_LIST}"]"|{ATTRIBUT void resetPythonCodeParserState() { + g_codeClassSDict.setAutoDelete(TRUE); + g_codeClassSDict.clear(); g_currentDefinition = 0; g_currentMemberDef = 0; g_doubleStringIsDoc = FALSE; @@ -1567,6 +1568,7 @@ void parsePythonCode(CodeOutputInterface &od,const char * /*className*/, //-------------------------------------- if (s.isEmpty()) return; printlex(yy_flex_debug, TRUE, __FILE__, fd ? fd->fileName().data(): NULL); + g_codeClassSDict.setAutoDelete(TRUE); TooltipManager::instance()->clearTooltips(); g_code = &od; g_inputString = s; -- cgit v0.12