Skip to content

Commit d1e1f87

Browse files
committed
Fix DrawNode memory leak
1 parent 736ce65 commit d1e1f87

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

axmol/2d/DrawNode.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,11 +1098,11 @@ void DrawNode::_drawCircle(const Vec2& center,
10981098

10991099
void DrawNode::_drawColoredTriangle(const Vec2* vertices3, const Color* color3)
11001100
{
1101-
unsigned int vertex_count = 3;
1102-
Vec2* _vertices3 = new Vec2[vertex_count];
1103-
applyLocalTransform(vertices3, _vertices3, vertex_count);
1101+
constexpr int VERTEX_COUNT = 3;
1102+
Vec2 _vertices3[VERTEX_COUNT];
1103+
applyLocalTransform(vertices3, _vertices3, VERTEX_COUNT);
11041104

1105-
auto triangles = reinterpret_cast<V2F_T2F_C4F_Triangle*>(expandBufferAndGetPointer(_triangles, vertex_count));
1105+
auto triangles = reinterpret_cast<V2F_T2F_C4F_Triangle*>(expandBufferAndGetPointer(_triangles, VERTEX_COUNT));
11061106
_trianglesDirty = true;
11071107

11081108
triangles[0] = {{_vertices3[0], Vec2::ZERO, color3[0]},

0 commit comments

Comments
 (0)