[Libreoffice-commits] core.git: Branch 'private/kohei/opencl-kernel-crash' - sc/source
Kohei Yoshida
kohei.yoshida at collabora.com
Thu Mar 6 13:01:26 PST 2014
sc/source/core/opencl/formulagroupcl.cxx | 45 ++++++++++++++-----------------
sc/source/core/opencl/opbase.hxx | 6 ++--
2 files changed, 24 insertions(+), 27 deletions(-)
New commits:
commit 65fb0f3877a3e176a1ec0bde37814247365c19c5
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date: Thu Mar 6 15:58:25 2014 -0500
Let's not leak ScTokenArray when compiling formula & some naming convention.
Names that begin with m_ are NOT to be used as local variables, and let's not
use a name that's identical to the name of a STL container.
Change-Id: I142cc76e9eb34a19a2346cbb67774d60b801a649
diff --git a/sc/source/core/opencl/formulagroupcl.cxx b/sc/source/core/opencl/formulagroupcl.cxx
index ec727a8..bd8c5eb 100644
--- a/sc/source/core/opencl/formulagroupcl.cxx
+++ b/sc/source/core/opencl/formulagroupcl.cxx
@@ -3358,45 +3358,44 @@ DynamicKernel* DynamicKernel::create(ScDocument& /* rDoc */,
ScTokenArray& rCode)
{
// Constructing "AST"
- FormulaTokenIterator aCode = rCode;
- std::list<FormulaToken *> list;
- std::map<FormulaToken *, FormulaTreeNodeRef> m_hash_map;
+ FormulaTokenIterator aCode(rCode);
+ std::list<FormulaToken*> aTokenList;
+ std::map<FormulaToken*, FormulaTreeNodeRef> aHashMap;
FormulaToken* pCur;
while( (pCur = (FormulaToken*)(aCode.Next()) ) != NULL)
{
OpCode eOp = pCur->GetOpCode();
if ( eOp != ocPush )
{
- FormulaTreeNodeRef m_currNode =
- FormulaTreeNodeRef(new FormulaTreeNode(pCur));
- sal_uInt8 m_ParamCount = pCur->GetParamCount();
- for(int i=0; i<m_ParamCount; i++)
+ FormulaTreeNodeRef pCurNode(new FormulaTreeNode(pCur));
+ sal_uInt8 nParamCount = pCur->GetParamCount();
+ for (sal_uInt8 i = 0; i < nParamCount; i++)
{
- FormulaToken* m_TempFormula = list.back();
- list.pop_back();
+ FormulaToken* m_TempFormula = aTokenList.back();
+ aTokenList.pop_back();
if(m_TempFormula->GetOpCode()!=ocPush)
{
- if(m_hash_map.find(m_TempFormula)==m_hash_map.end())
+ if (aHashMap.find(m_TempFormula)==aHashMap.end())
return NULL;
- m_currNode->Children.push_back(m_hash_map[m_TempFormula]);
+ pCurNode->Children.push_back(aHashMap[m_TempFormula]);
}
else
{
FormulaTreeNodeRef m_ChildTreeNode =
FormulaTreeNodeRef(
new FormulaTreeNode(m_TempFormula));
- m_currNode->Children.push_back(m_ChildTreeNode);
+ pCurNode->Children.push_back(m_ChildTreeNode);
}
}
- std::reverse(m_currNode->Children.begin(),
- m_currNode->Children.end());
- m_hash_map[pCur] = m_currNode;
+ std::reverse(pCurNode->Children.begin(),
+ pCurNode->Children.end());
+ aHashMap[pCur] = pCurNode;
}
- list.push_back(pCur);
+ aTokenList.push_back(pCur);
}
FormulaTreeNodeRef Root = FormulaTreeNodeRef(new FormulaTreeNode(NULL));
- Root->Children.push_back(m_hash_map[list.back()]);
+ Root->Children.push_back(aHashMap[aTokenList.back()]);
DynamicKernel* pDynamicKernel = new DynamicKernel(Root);
@@ -3431,16 +3430,14 @@ CompiledFormula* FormulaGroupInterpreterOpenCL::createCompiledFormula(ScDocument
ScFormulaCellGroupRef& xGroup,
ScTokenArray& rCode)
{
- ScTokenArray *pCode = new ScTokenArray();
- ScGroupTokenConverter aConverter(*pCode, rDoc, *xGroup->mpTopCell, rTopPos);
- if (!aConverter.convert(rCode) || pCode->GetLen() == 0)
- {
- delete pCode;
+ ScTokenArray aConvertedCode;
+ ScGroupTokenConverter aConverter(aConvertedCode, rDoc, *xGroup->mpTopCell, rTopPos);
+ if (!aConverter.convert(rCode) || aConvertedCode.GetLen() == 0)
return NULL;
- }
+
SymbolTable::nR = xGroup->mnLength;
- return DynamicKernel::create(rDoc, rTopPos, *pCode);
+ return DynamicKernel::create(rDoc, rTopPos, aConvertedCode);
}
bool FormulaGroupInterpreterOpenCL::interpret( ScDocument& rDoc,
diff --git a/sc/source/core/opencl/opbase.hxx b/sc/source/core/opencl/opbase.hxx
index f5ceac5..a75e160 100644
--- a/sc/source/core/opencl/opbase.hxx
+++ b/sc/source/core/opencl/opbase.hxx
@@ -128,17 +128,17 @@ typedef boost::shared_ptr<FormulaTreeNode> FormulaTreeNodeRef;
class FormulaTreeNode
{
public:
- FormulaTreeNode(formula::FormulaToken *ft): mpCurrentFormula(ft)
+ FormulaTreeNode(const formula::FormulaToken* ft): mpCurrentFormula(ft)
{
Children.reserve(8);
}
std::vector<FormulaTreeNodeRef> Children;
formula::FormulaToken *GetFormulaToken(void) const
{
- return mpCurrentFormula;
+ return const_cast<formula::FormulaToken*>(mpCurrentFormula.get());
}
private:
- formula::FormulaToken *const mpCurrentFormula;
+ formula::FormulaConstTokenRef mpCurrentFormula;
};
/// (Partially) abstract base class for an operand
More information about the Libreoffice-commits
mailing list