[Libreoffice-commits] core.git: starmath/inc starmath/source
Takeshi Abe
tabe at fixedpoint.jp
Mon Nov 3 03:17:43 PST 2014
starmath/inc/parse.hxx | 4 ++--
starmath/source/parse.cxx | 16 ++++++----------
2 files changed, 8 insertions(+), 12 deletions(-)
New commits:
commit fe1f258d5b77cd6e6a7483d7cf28195dbfdd62a4
Author: Takeshi Abe <tabe at fixedpoint.jp>
Date: Mon Nov 3 08:42:02 2014 +0900
fix memory leak of pointers contained in m_aErrDescList
Change-Id: I9fcbdcd54978ccaffa5359c0afb0a1990356c218
Reviewed-on: https://gerrit.libreoffice.org/12205
Reviewed-by: David Tardon <dtardon at redhat.com>
Tested-by: David Tardon <dtardon at redhat.com>
diff --git a/starmath/inc/parse.hxx b/starmath/inc/parse.hxx
index 7f59def..376113c 100644
--- a/starmath/inc/parse.hxx
+++ b/starmath/inc/parse.hxx
@@ -27,7 +27,7 @@
#include "types.hxx"
-#include <vector>
+#include <boost/ptr_container/ptr_vector.hpp>
class SmNode;
@@ -157,7 +157,7 @@ struct SmErrorDesc
typedef ::std::stack< SmNode* > SmNodeStack;
-typedef ::std::vector< SmErrorDesc* > SmErrDescList;
+typedef boost::ptr_vector< SmErrorDesc > SmErrDescList;
/**************************************************************************/
diff --git a/starmath/source/parse.cxx b/starmath/source/parse.cxx
index 408612e..c1757bf 100644
--- a/starmath/source/parse.cxx
+++ b/starmath/source/parse.cxx
@@ -2406,8 +2406,6 @@ SmNode *SmParser::Parse(const OUString &rBuffer)
m_nColOff = 0;
m_nCurError = -1;
- for ( size_t i = 0, n = m_aErrDescList.size(); i < n; ++i )
- delete m_aErrDescList[ i ];
m_aErrDescList.clear();
while ( !m_aNodeStack.empty() )
@@ -2430,8 +2428,6 @@ SmNode *SmParser::ParseExpression(const OUString &rBuffer)
m_nColOff = 0;
m_nCurError = -1;
- for ( size_t i = 0, n = m_aErrDescList.size(); i < n; ++i )
- delete m_aErrDescList[ i ];
m_aErrDescList.clear();
while ( !m_aNodeStack.empty() )
@@ -2485,11 +2481,11 @@ size_t SmParser::AddError(SmParseError Type, SmNode *pNode)
const SmErrorDesc *SmParser::NextError()
{
if ( !m_aErrDescList.empty() )
- if (m_nCurError > 0) return m_aErrDescList[ --m_nCurError ];
+ if (m_nCurError > 0) return &m_aErrDescList[ --m_nCurError ];
else
{
m_nCurError = 0;
- return m_aErrDescList[ m_nCurError ];
+ return &m_aErrDescList[ m_nCurError ];
}
else return NULL;
}
@@ -2498,11 +2494,11 @@ const SmErrorDesc *SmParser::NextError()
const SmErrorDesc *SmParser::PrevError()
{
if ( !m_aErrDescList.empty() )
- if (m_nCurError < (int) (m_aErrDescList.size() - 1)) return m_aErrDescList[ ++m_nCurError ];
+ if (m_nCurError < (int) (m_aErrDescList.size() - 1)) return &m_aErrDescList[ ++m_nCurError ];
else
{
m_nCurError = (int) (m_aErrDescList.size() - 1);
- return m_aErrDescList[ m_nCurError ];
+ return &m_aErrDescList[ m_nCurError ];
}
else return NULL;
}
@@ -2511,10 +2507,10 @@ const SmErrorDesc *SmParser::PrevError()
const SmErrorDesc *SmParser::GetError(size_t i)
{
if ( i < m_aErrDescList.size() )
- return m_aErrDescList[ i ];
+ return &m_aErrDescList[ i ];
if ( (size_t)m_nCurError < m_aErrDescList.size() )
- return m_aErrDescList[ m_nCurError ];
+ return &m_aErrDescList[ m_nCurError ];
return NULL;
}
More information about the Libreoffice-commits
mailing list