[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: kdelibs/kate/part
From: Christoph Cullmann <cullmann () kde ! org>
Date: 2004-10-24 20:39:10
Message-ID: 20041024203910.7F0BC16B9D () office ! kde ! org
[Download RAW message or body]
CVS commit by cullmann:
BIG memleak fix for load, please backport after more testing
BUG: 91860
M +29 -15 katebuffer.cpp 1.206
M +4 -13 katetextline.h 1.69
--- kdelibs/kate/part/katebuffer.cpp #1.205:1.206
@@ -149,8 +149,13 @@ class KateFileLoader
inline int eol () const { return m_eol; }
- // read a line, return per reference, only valid until the next readLine call
- // or until this object goes to trash !!!
- QConstString readLine ()
+ // internal unicode data array
+ inline const QChar *unicode () const { return m_text.unicode(); }
+
+ // read a line, return length + offset in unicode data
+ void readLine (uint &offset, uint &length)
{
+ length = 0;
+ offset = 0;
+
while (m_position <= m_text.length())
{
@@ -181,8 +186,11 @@ class KateFileLoader
lastWasEndOfLine = false;
- QConstString line = QConstString (m_text.unicode()+m_lastLineStart, \
m_position-m_lastLineStart); + // line data
+ offset = m_lastLineStart;
+ length = m_position-m_lastLineStart;
+
m_lastLineStart = m_position;
- return line;
+ return;
}
}
@@ -199,9 +207,12 @@ class KateFileLoader
else
{
- QConstString line = QConstString (m_text.unicode()+m_lastLineStart, \
m_position-m_lastLineStart); + // line data
+ offset = m_lastLineStart;
+ length = m_position-m_lastLineStart;
+
m_lastLineStart = m_position+1;
m_position++;
- return line;
+ return;
}
}
@@ -211,9 +222,12 @@ class KateFileLoader
lastWasR = true;
- QConstString line = QConstString (m_text.unicode()+m_lastLineStart, \
m_position-m_lastLineStart); + // line data
+ offset = m_lastLineStart;
+ length = m_position-m_lastLineStart;
+
m_lastLineStart = m_position+1;
m_position++;
- return line;
+ return;
}
else
@@ -225,6 +239,4 @@ class KateFileLoader
m_position++;
}
-
- return QConstString (m_text.unicode(), 0);
}
@@ -1189,6 +1201,8 @@ void KateBufBlock::fillBlock (KateFileLo
while (!stream->eof() && (blockSize < KATE_AVG_BLOCK_SIZE) && (m_lines < \
KATE_MAX_BLOCK_LINES)) {
- QConstString line = stream->readLine();
- uint length = line.string().length ();
+ uint offset = 0, length = 0;
+ stream->readLine(offset, length);
+ QChar *unicodeData = stream->unicode () + offset;
+
blockSize += length;
@@ -1215,5 +1229,5 @@ void KateBufBlock::fillBlock (KateFileLo
pos += sizeof(uint);
- memcpy(buf+pos, (char *) line.string().unicode(), sizeof(QChar)*length);
+ memcpy(buf+pos, (char *) unicodeData, sizeof(QChar)*length);
pos += sizeof(QChar)*length;
}
@@ -1221,5 +1235,5 @@ void KateBufBlock::fillBlock (KateFileLo
{
KateTextLine::Ptr textLine = new KateTextLine ();
- textLine->insertText (0, length, line.string().unicode ());
+ textLine->insertText (0, length, unicodeData);
m_stringList.push_back (textLine);
}
--- kdelibs/kate/part/katetextline.h #1.68:1.69
@@ -175,13 +175,4 @@ class KateTextLine : public KShared
/**
- * Gets a substring as constant string.
- * @param startCol start column of substring
- * @param length lenght of substring
- * @return wanted substring
- */
- inline QConstString constString(uint startCol, uint length) const
- { return QConstString(m_text.unicode() + startCol, length); }
-
- /**
* Gets a null terminated pointer to first non space char
* @return array of QChars starting at first non-whitespace char
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic