Some problems in the OctTree.h

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
genius982
Posts: 3
Joined: Sat Dec 13, 2008 8:44 am

Some problems in the OctTree.h

Post by genius982 »

Look the following codes in OctTree
...
OctTree(const core::array<SMeshChunk>& meshes, s32 minimalPolysPerNode=128)
{
nodeCount = 0;

IndexDataCount = meshes.size();

//some problems here
IndexData = new SIndexData[IndexDataCount];

core::array<SIndexChunk>* indexChunks = new core::array<SIndexChunk>;
SIndexChunk ic;

for (u32 i=0; i<meshes.size(); ++i)
{
IndexData.CurrentSize = 0;
IndexData.MaxSize = meshes.Indices.size();
IndexData.Indices = new u16[IndexData.MaxSize];

ic.MaterialId = meshes.MaterialId;
indexChunks->push_back(ic);

SIndexChunk& tic = (*indexChunks);

for (u32 t=0; t<meshes.Indices.size(); ++t)
tic.Indices.push_back(meshes.Indices[t]);
}

// create tree

Root = new OctTreeNode(nodeCount, 0, meshes, indexChunks, minimalPolysPerNode);
}
and the construction of OctTreeNode
OctTreeNode(u32& nodeCount, u32 currentdepth,
const core::array<SMeshChunk>& allmeshdata,
core::array<SIndexChunk>* indices,
s32 minimalPolysPerNode) : IndexData(0),
Depth(currentdepth+1)
the pointer IndexData is reset to NULL without deleting original datas.
So I'm a little fuzzle will it cause memory leak?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

OctTree::IndexData is not the same as OctTreeNode::IndexData.

Is there some specific reason why you think this is causing a problem? Valgrinding example 2 reports some leaks in glX, but nothing in OctTree.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
genius982
Posts: 3
Joined: Sat Dec 13, 2008 8:44 am

Post by genius982 »

Thank you. Now I understand.
Post Reply