-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 @@ -56,47 +56,47 @@ #define HERE printf("%s(%d): here\n",__FILE__,__LINE__) //FIXME: this is emulation specific. Use FALSE for xterm, TRUE for ANSI. //FIXME: see if we can get this from terminfo. #define BS_CLEARS FALSE #define loc(X,Y) ((Y) * columns + (X)) /*! creates a `TEScreen' of `lines' lines and `columns' columns. */ -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(); clearSelection(); reset(); } /*! Destructor */ TEScreen::~TEScreen() { - free(image); - if (tabstops) free(tabstops); + delete [] image; + delete [] tabstops; } /* ------------------------------------------------------------------------- */ /* */ /* Normalized Screen Operations */ /* */ /* ------------------------------------------------------------------------- */ // Cursor Setting -------------------------------------------------------------- /*! \section Cursor @@ -387,47 +387,47 @@ void TEScreen::restoreCursor() void TEScreen::resizeImage(int new_lines, int new_columns) { if (cuY > new_lines-1) { // attempt to preserve focus and lines bmargin = lines-1; //FIXME: margin lost for (int i = 0; i < cuY-(new_lines-1); i++) { addHistLine(); scrollUp(horzCursor,1); } } // make new image - ca* newimg = (ca*)malloc( new_lines * new_columns * sizeof( ca)); + ca* newimg = new ca[new_lines * new_columns]; clearSelection(); // clear new image for (int y = 0; y < new_lines; y++) for (int x = 0; x < new_columns; x++) { newimg[y*new_columns+x].c = ' '; newimg[y*new_columns+x].f = DEFAULT_FORE_COLOR; newimg[y*new_columns+x].b = DEFAULT_BACK_COLOR; newimg[y*new_columns+x].r = DEFAULT_RENDITION; } int cpy_lines = QMIN(new_lines, lines); int cpy_columns = QMIN(new_columns,columns); // copy to new image for (int y = 0; y < cpy_lines; y++) for (int x = 0; x < cpy_columns; x++) { newimg[y*new_columns+x].c = image[loc(x,y)].c; newimg[y*new_columns+x].f = image[loc(x,y)].f; newimg[y*new_columns+x].b = image[loc(x,y)].b; newimg[y*new_columns+x].r = image[loc(x,y)].r; } - free(image); + delete [] image; image = newimg; lines = new_lines; columns = new_columns; cuX = QMIN(cuX,columns-1); cuY = QMIN(cuY,lines-1); // FIXME: try to keep values, evtl. tmargin=0; bmargin=lines-1; initTabStops(); clearSelection(); } @@ -498,25 +498,25 @@ void TEScreen::effectiveRendition() returns the image. Get the size of the image by \sa getLines and \sa getColumns. NOTE that the image returned by this function must later be freed. */ 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); if (histCursor > hist.getLines()) { histCursor = hist.getLines(); } for (y = 0; (y < lines) && (y < (hist.getLines()-histCursor)); y++) { int len = QMIN(columns,hist.getLineLen(y+histCursor)); int yp = y*columns; int yq = (y+histCursor)*columns; @@ -614,26 +614,28 @@ void TEScreen::clearTabStops() { for (int i = 0; i < columns; i++) tabstops[i-1] = FALSE; } void TEScreen::changeTabStop(bool set) { if (cuX >= columns) return; tabstops[cuX] = set; } 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. // i.e. the kids start counting from 0 instead of 1. // Other programs might behave correctly. Be aware. for (int i = 0; i < columns; i++) tabstops[i] = (i%8 == 0 && i != 0); } /*! This behaves either as IND (Screen::Index) or as NEL (Screen::NextLine) depending on the NewLine Mode (LNM). This mode also affects the key sequence returned for newline ([CR]LF). */ 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 @@ -50,33 +50,34 @@ CPPMLanguageModel::CPPMnode * CPPMLanguageModel::CPPMnode::add_symbol_to_node(in } return search; } } ///////////////////////////////////////////////////////////////////// // CPPMLanguageModel defs ///////////////////////////////////////////////////////////////////// CPPMLanguageModel::CPPMLanguageModel(CAlphabet *_alphabet,int _normalization) - : CLanguageModel(_alphabet,_normalization) + : CLanguageModel(_alphabet,_normalization), root(0), m_rootcontext(0) { root=new CPPMnode(-1); m_rootcontext=new CPPMContext(root,0); } CPPMLanguageModel::~CPPMLanguageModel() { + delete m_rootcontext; delete root; } bool CPPMLanguageModel::GetProbs(CContext *context,vector<unsigned int> &probs,double ) // get the probability distribution at the context { // seems like we have to have this hack for VC++ CPPMContext *ppmcontext=static_cast<CPPMContext *> (context); int modelchars=GetNumberModelChars(); 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 @@ -1,34 +1,50 @@ #include <qmessagebox.h> #include "Bkmks.h" #include "StyleConsts.h" #include "Markups.h" #include "my_list.h" #include "version.h" #include "names.h" const unsigned long BkmkFile::magic = ((unsigned long)'q' << 24) | ((unsigned long)'t' << 16) | ((unsigned long)'r' << 8) | ((unsigned long)BKMKTYPE); -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) { init(_nm, _nmlen, _anno, _annolen, _p); } Bkmk::Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short annolen, unsigned int _p) : m_position(_p) { init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, annolen, _p); } +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) { if (_anno == NULL) { tchar t = 0; init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), &t, sizeof(t), _p); } else { init(_nm, sizeof(tchar)*(ustrlen(_nm)+1), _anno, sizeof(tchar)*(ustrlen(_anno)+1), _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 @@ -11,33 +11,30 @@ class CList; class Bkmk { friend class BkmkFile; unsigned char* m_name; unsigned short m_namelen; unsigned char* m_anno; unsigned short m_annolen; unsigned int m_position; unsigned int m_position2; unsigned char m_red,m_green,m_blue, m_level; void init(const void*, unsigned short, const void*, unsigned short, unsigned int); 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); Bkmk(const tchar* _nm, const unsigned char* _anno, unsigned short _annolen, unsigned int _p); Bkmk(const tchar* _nm, const tchar* _anno, unsigned int _p); 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(); unsigned int value() const { return m_position; } void value(unsigned int _v) { m_position = _v; } unsigned int value2() const { return m_position2; } void value2(unsigned int _v) { m_position2 = _v; } unsigned char red() { return m_red; } unsigned char green() { return m_green; } unsigned char blue() { return m_blue; } void red(unsigned char _v) { m_red = _v; } void green(unsigned char _v) { m_green = _v; } void blue(unsigned char _v) { m_blue = _v; } unsigned char level() { return m_level; } 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 @@ -1,18 +1,25 @@ #include <qimage.h> #include "StyleConsts.h" 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() { //// qDebug("Deleting image"); delete graphic; } CStyle::~CStyle() { if (graphic != NULL) { if (--(graphic->count) == 0) { 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 @@ -12,33 +12,31 @@ typedef unsigned short StyleType; class QImage; struct GraphicLink { QImage* graphic; bool isLink; unsigned long link; GraphicLink(QImage* p, bool isLnk, unsigned long tgt) : graphic(p), isLink(isLnk), link(tgt) {} ~GraphicLink(); }; -struct pmstore +class pmstore { + public: unsigned int count; bool m_isScaleable; 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(); }; enum EalignmentType { m_AlignLeft, m_AlignRight, m_AlignCentre, m_AlignJustify, m_AlignNone }; 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 @@ -6051,33 +6051,32 @@ QTextFormat QTextFormat::makeTextFormat( const QStyleSheetItem *style, const QMa struct QPixmapInt { QPixmapInt() : ref( 0 ) {} QPixmap pm; int ref; }; static QMap<QString, QPixmapInt> *pixmap_map = 0; QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, const QString& context, QMimeSourceFactory &factory ) - : QTextCustomItem( p ) + : QTextCustomItem( p ), reg( 0 ) { width = height = 0; if ( attr.contains("width") ) width = attr["width"].toInt(); if ( attr.contains("height") ) height = attr["height"].toInt(); - reg = 0; QString imageName = attr["src"]; if (!imageName) imageName = attr["source"]; if ( !imageName.isEmpty() ) { imgId = QString( "%1,%2,%3,%4" ).arg( imageName ).arg( width ).arg( height ).arg( (ulong)&factory ); if ( !pixmap_map ) pixmap_map = new QMap<QString, QPixmapInt>; if ( pixmap_map->contains( imgId ) ) { QPixmapInt& pmi = pixmap_map->operator[](imgId); pm = pmi.pm; @@ -6140,36 +6139,36 @@ QTextImage::QTextImage( QTextDocument *p, const QMap<QString, QString> &attr, co place = PlaceLeft; else if ( attr["align"] == "right" ) place = PlaceRight; tmpwidth = width; tmpheight = height; attributes = attr; } QTextImage::~QTextImage() { + delete reg; if ( pixmap_map && pixmap_map->contains( imgId ) ) { QPixmapInt& pmi = pixmap_map->operator[](imgId); pmi.ref--; if ( !pmi.ref ) { pixmap_map->remove( imgId ); if ( pixmap_map->isEmpty() ) { delete pixmap_map; pixmap_map = 0; } } } - delete reg; } QString QTextImage::richText() const { QString s; s += "<img "; QMap<QString, QString>::ConstIterator it = attributes.begin(); for ( ; it != attributes.end(); ++it ) s += it.key() + "=" + *it + " "; s += ">"; return s; } 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 @@ -380,31 +380,36 @@ HlAnyChar::HlAnyChar(int attribute, int context, const QChar* charList, uint len : HlItem(attribute, context) { _charList=charList; _charListLen=len; } const QChar *HlAnyChar::checkHgl(const QChar *s, int len, bool) { if (ustrchr(_charList, _charListLen, *s)) return s +1; return 0L; } HlRegExpr::HlRegExpr(int attribute, int context,QString regexp) - : HlItem(attribute, context) { + : HlItem(attribute, context), Expr(0) { handlesLinestart=regexp.startsWith("^"); if(!handlesLinestart) regexp.prepend("^"); Expr=new QRegExp3(regexp); } +HlRegExpr::~HlRegExpr() +{ + delete Expr; +} + const QChar *HlRegExpr::checkHgl(const QChar *s, int len, bool lineStart) { if ((!lineStart) && handlesLinestart) return 0; QString line(s,len); int pos = Expr->search( line, 0 ); if (pos==-1) return 0L; else return (s+Expr->matchedLength()); }; 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 @@ -175,25 +175,25 @@ class HlCChar : public HlItem { class HlAnyChar : public HlItem { public: HlAnyChar(int attribute, int context, const QChar* charList, uint len); virtual const QChar *checkHgl(const QChar *, int len, bool); const QChar* _charList; uint _charListLen; }; class HlRegExpr : public HlItem { public: HlRegExpr(int attribute, int context,QString expr); - ~HlRegExpr(){delete Expr;}; + ~HlRegExpr(); virtual const QChar *checkHgl(const QChar *, int len, bool); QRegExp3 *Expr; bool handlesLinestart; }; //-------- //Item Style: color, selected color, bold, italic class ItemStyle { public: ItemStyle(); |