Sfoglia il codice sorgente

Fixed tool memory leak.

bkaradzic 13 anni fa
parent
commit
6f3cc509e4
3 ha cambiato i file con 10 aggiunte e 3 eliminazioni
  1. 2 0
      examples/06-bump/bump.cpp
  2. 6 3
      src/vertexdecl.cpp
  3. 2 0
      tools/geometryc/geometryc.cpp

+ 2 - 0
examples/06-bump/bump.cpp

@@ -244,6 +244,8 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl
 		tangent[3] = vec3Dot(nxt, tanv) < 0.0f ? -1.0f : 1.0f;
 		tangent[3] = vec3Dot(nxt, tanv) < 0.0f ? -1.0f : 1.0f;
 		bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _decl, _vertices, ii);
 		bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _decl, _vertices, ii);
 	}
 	}
+
+	delete [] tangents;
 } 
 } 
 
 
 int _main_(int _argc, char** _argv)
 int _main_(int _argc, char** _argv)

+ 6 - 3
src/vertexdecl.cpp

@@ -9,6 +9,9 @@
 
 
 #include "vertexdecl.h"
 #include "vertexdecl.h"
 
 
+extern void dbgPrintf(const char* _format, ...);
+extern void dbgPrintfData(const void* _data, uint32_t _size, const char* _format, ...);
+
 namespace bgfx
 namespace bgfx
 {
 {
 	static const uint8_t s_attribTypeSizeDx9[AttribType::Count][4] =
 	static const uint8_t s_attribTypeSizeDx9[AttribType::Count][4] =
@@ -114,9 +117,9 @@ namespace bgfx
 	void dump(const VertexDecl& _decl)
 	void dump(const VertexDecl& _decl)
 	{
 	{
 #if BGFX_CONFIG_DEBUG
 #if BGFX_CONFIG_DEBUG
-		BX_TRACE("vertexdecl %08x (%08x), stride %d"
+		dbgPrintf("vertexdecl %08x (%08x), stride %d"
 			, _decl.m_hash
 			, _decl.m_hash
-			, hashMurmur2A(_decl.m_attributes, sizeof(_decl.m_attributes) )
+			, bx::hashMurmur2A(_decl.m_attributes, sizeof(_decl.m_attributes) )
 			, _decl.m_stride
 			, _decl.m_stride
 			);
 			);
 
 
@@ -130,7 +133,7 @@ namespace bgfx
 				bool asInt;
 				bool asInt;
 				_decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
 				_decl.decode(Attrib::Enum(attr), num, type, normalized, asInt);
 
 
-				BX_TRACE("\tattr %d - %s, num %d, type %d, norm %d, asint %d, offset %d"
+				dbgPrintf("\tattr %d - %s, num %d, type %d, norm %d, asint %d, offset %d"
 					, attr
 					, attr
 					, getAttribName(Attrib::Enum(attr) )
 					, getAttribName(Attrib::Enum(attr) )
 					, num
 					, num

+ 2 - 0
tools/geometryc/geometryc.cpp

@@ -230,6 +230,8 @@ void calcTangents(void* _vertices, uint16_t _numVertices, bgfx::VertexDecl _decl
 		tangent[3] = vec3Dot(nxt, tanv) < 0.0f ? -1.0f : 1.0f;
 		tangent[3] = vec3Dot(nxt, tanv) < 0.0f ? -1.0f : 1.0f;
 		bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _decl, _vertices, ii);
 		bgfx::vertexPack(tangent, true, bgfx::Attrib::Tangent, _decl, _vertices, ii);
 	}
 	}
+
+	delete [] tangents;
 } 
 } 
 
 
 void writeBounds(bx::WriterI* _writer, const void* _vertices, uint32_t _numVertices, uint32_t _stride)
 void writeBounds(bx::WriterI* _writer, const void* _vertices, uint32_t _numVertices, uint32_t _stride)