author | erik <erik> | 2007-01-19 01:12:38 (UTC) |
---|---|---|
committer | erik <erik> | 2007-01-19 01:12:38 (UTC) |
commit | 1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7 (patch) (side-by-side diff) | |
tree | af4a12bc46e25853386dc53868b869e1bf05d863 | |
parent | 2b45dc71e79a3eb7d4e8553273c9bc4f4282d50a (diff) | |
download | opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.zip opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.gz opie-1ab92f1d2b346de7da8ca5c3aaa6bc75b43981e7.tar.bz2 |
Every single file in this commit had a memory leak where a resource is
allocated in the constructor but not de-allocated in the destructor.
This commit fixes that.
-rw-r--r-- | core/apps/embeddedkonsole/TEScreen.cpp | 32 | ||||
-rw-r--r-- | inputmethods/dasher/PPMLanguageModel.cpp | 3 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.cpp | 18 | ||||
-rw-r--r-- | noncore/apps/opie-reader/Bkmks.h | 7 | ||||
-rw-r--r-- | noncore/apps/opie-reader/StyleConsts.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/opie-reader/StyleConsts.h | 8 | ||||
-rw-r--r-- | noncore/apps/opie-write/qrichtext.cpp | 5 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katehighlight.cpp | 7 | ||||
-rw-r--r-- | noncore/apps/tinykate/libkate/document/katehighlight.h | 2 |
9 files changed, 57 insertions, 32 deletions
diff --git a/core/apps/embeddedkonsole/TEScreen.cpp b/core/apps/embeddedkonsole/TEScreen.cpp index 1db34d2..30ff49d 100644 --- a/core/apps/embeddedkonsole/TEScreen.cpp +++ b/core/apps/embeddedkonsole/TEScreen.cpp @@ -67,13 +67,13 @@ -TEScreen::TEScreen(int lines, int columns) +TEScreen::TEScreen(int _lines, int _columns) : + lines(_lines), + columns(_columns), + tabstops(0), + histCursor(0), + horzCursor(0) { - this->lines = lines; - this->columns = columns; // odebug << "Columns " << columns << "" << oendl; - image = (ca*) malloc(lines*columns*sizeof(ca)); - tabstops = NULL; initTabStops(); - - histCursor = 0; - horzCursor = 0; + image = new ca[lines*columns]; + initTabStops(); @@ -88,4 +88,4 @@ TEScreen::~TEScreen() { - free(image); - if (tabstops) free(tabstops); + delete [] image; + delete [] tabstops; } @@ -398,3 +398,3 @@ void TEScreen::resizeImage(int new_lines, int new_columns) // make new image - ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); + ca* newimg = new ca[new_lines * new_columns]; @@ -420,3 +420,3 @@ void TEScreen::resizeImage(int new_lines, int new_columns) } - free(image); + delete [] image; image = newimg; @@ -509,3 +509,3 @@ ca* TEScreen::getCookedImage() int x,y; - ca* merged = (ca*)malloc(lines*columns*sizeof(ca)); + ca* merged = new ca[lines*columns]; ca dft(' ',DEFAULT_FORE_COLOR,DEFAULT_BACK_COLOR,DEFAULT_RENDITION); @@ -625,4 +625,6 @@ void TEScreen::initTabStops() { - if (tabstops) free(tabstops); - tabstops = (bool*)malloc(columns*sizeof(bool)); + if (tabstops) + delete [] tabstops; + + tabstops = new bool[columns]; // Arrg! The 1st tabstop has to be one longer than the other. diff --git a/inputmethods/dasher/PPMLanguageModel.cpp b/inputmethods/dasher/PPMLanguageModel.cpp index 137b07f..d767d16 100644 --- a/inputmethods/dasher/PPMLanguageModel.cpp +++ b/inputmethods/dasher/PPMLanguageModel.cpp @@ -61,3 +61,3 @@ CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(in CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization) - : CLanguageModel(_alphabet,_normalization) + : CLanguageModel(_alphabet,_normalization), root(0), m_rootcontext(0) { @@ -70,2 +70,3 @@ CPPMLanguageModel::~CPPMLanguageModel() { + delete m_rootcontext; delete root; diff --git a/noncore/apps/opie-reader/Bkmks.cpp b/noncore/apps/opie-reader/Bkmks.cpp index 440d8be..28f6318 100644 --- a/noncore/apps/opie-reader/Bkmks.cpp +++ b/noncore/apps/opie-reader/Bkmks.cpp @@ -12,3 +12,8 @@ const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned lo -Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) +Bkmk::Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p) : + m_name(0), + m_namelen(0), + m_anno(0), + m_annolen(0), + m_position(0) { @@ -22,2 +27,13 @@ Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, +Bkmk::Bkmk(const Bkmk& rhs) : + m_name(0), + m_namelen(0), + m_anno(0), + m_annolen(0), + m_position(0) +{ + init(rhs.name(), sizeof(tchar)*(ustrlen(rhs.name())+1), rhs.anno(), + sizeof(tchar)*(ustrlen(rhs.anno())+1), rhs.value()); +} + Bkmk::Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p) : m_position(_p) diff --git a/noncore/apps/opie-reader/Bkmks.h b/noncore/apps/opie-reader/Bkmks.h index c2275e2..985e158 100644 --- a/noncore/apps/opie-reader/Bkmks.h +++ b/noncore/apps/opie-reader/Bkmks.h @@ -22,3 +22,3 @@ class Bkmk public: - Bkmk() : m_name(NULL), m_namelen(0), m_anno(NULL), m_annolen(0), m_position(0) {}; + Bkmk() : m_name(0), m_namelen(0), m_anno(0), m_annolen(0), m_position(0) {}; Bkmk(const unsigned char* _nm, unsigned short _nmlen, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); @@ -27,6 +27,3 @@ class Bkmk Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p, unsigned int _p2); - Bkmk(const Bkmk& rhs) : m_name(NULL), m_anno(NULL) - { - *this = rhs; - } + Bkmk(const Bkmk& rhs); ~Bkmk(); diff --git a/noncore/apps/opie-reader/StyleConsts.cpp b/noncore/apps/opie-reader/StyleConsts.cpp index 77c9d3b..c19fa3d 100644 --- a/noncore/apps/opie-reader/StyleConsts.cpp +++ b/noncore/apps/opie-reader/StyleConsts.cpp @@ -6,2 +6,9 @@ GraphicLink::~GraphicLink() { delete graphic; } +pmstore::pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : + count(1), + m_isScaleable(_canScale) +{ + graphic = new GraphicLink(p, isLnk, tgt); +} + pmstore::~pmstore() diff --git a/noncore/apps/opie-reader/StyleConsts.h b/noncore/apps/opie-reader/StyleConsts.h index 4b7ff4b..5fd9669 100644 --- a/noncore/apps/opie-reader/StyleConsts.h +++ b/noncore/apps/opie-reader/StyleConsts.h @@ -23,4 +23,5 @@ struct GraphicLink -struct pmstore +class pmstore { + public: unsigned int count; @@ -28,6 +29,3 @@ struct pmstore GraphicLink* graphic; - pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt) : count(1), m_isScaleable(_canScale) - { - graphic = new GraphicLink(p, isLnk, tgt); - } + pmstore(bool _canScale, QImage* p, bool isLnk, unsigned long tgt); ~pmstore(); diff --git a/noncore/apps/opie-write/qrichtext.cpp b/noncore/apps/opie-write/qrichtext.cpp index c27eb1e..f040f1e 100644 --- a/noncore/apps/opie-write/qrichtext.cpp +++ b/noncore/apps/opie-write/qrichtext.cpp @@ -6062,3 +6062,3 @@ QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, co QMimeSourceFactory &factory ) - : QTextCustomItem( p ) + : QTextCustomItem( p ), reg( 0 ) { @@ -6070,3 +6070,2 @@ QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, co - reg = 0; QString imageName = attr["src"]; @@ -6151,2 +6150,3 @@ QTextImage::~QTextImage() { + delete reg; if ( pixmap_map && pixmap_map->contains( imgId ) ) { @@ -6162,3 +6162,2 @@ QTextImage::~QTextImage() } - delete reg; } diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.cpp b/noncore/apps/tinykate/libkate/document/katehighlight.cpp index 539d356..89024f7 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.cpp +++ b/noncore/apps/tinykate/libkate/document/katehighlight.cpp @@ -391,3 +391,3 @@ const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) - : HlItem(attribute, context) { + : HlItem(attribute, context), Expr(0) { @@ -398,2 +398,7 @@ HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) +HlRegExpr::~HlRegExpr() +{ + delete Expr; +} + const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) diff --git a/noncore/apps/tinykate/libkate/document/katehighlight.h b/noncore/apps/tinykate/libkate/document/katehighlight.h index fddf585..f0be27b 100644 --- a/noncore/apps/tinykate/libkate/document/katehighlight.h +++ b/noncore/apps/tinykate/libkate/document/katehighlight.h @@ -186,3 +186,3 @@ class HlRegExpr : public HlItem { HlRegExpr(int attribute, int context,QString expr); - ~HlRegExpr(){delete Expr;}; + ~HlRegExpr(); virtual const QChar *checkHgl(const QChar *, int len, bool); |