[Scummvm-cvs-logs] SF.net SVN: scummvm:[50680] tools/branches/gsoc2010-decompiler/decompiler

pidgeot at users.sourceforge.net pidgeot at users.sourceforge.net
Mon Jul 5 16:51:22 CEST 2010


Revision: 50680
          http://scummvm.svn.sourceforge.net/scummvm/?rev=50680&view=rev
Author:   pidgeot
Date:     2010-07-05 14:51:22 +0000 (Mon, 05 Jul 2010)

Log Message:
-----------
Fix memory leaks

Modified Paths:
--------------
    tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
    tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
    tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h

Modified: tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp	2010-07-05 14:46:09 UTC (rev 50679)
+++ tools/branches/gsoc2010-decompiler/decompiler/control_flow.cpp	2010-07-05 14:51:22 UTC (rev 50680)
@@ -67,6 +67,8 @@
 	}
 }
 
+
+
 GraphVertex ControlFlow::find(const Instruction &inst) {
 	return _addrMap[inst._address];
 }
@@ -111,6 +113,8 @@
 	boost::clear_vertex(g2, _g);
 	// Remove vertex
 	boost::remove_vertex(g2, _g);
+	// Delete old group
+	delete gr2;
 }
 
 void ControlFlow::setStackLevel(GraphVertex g, int level) {

Modified: tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp	2010-07-05 14:46:09 UTC (rev 50679)
+++ tools/branches/gsoc2010-decompiler/decompiler/decompiler.cpp	2010-07-05 14:51:22 UTC (rev 50680)
@@ -121,6 +121,8 @@
 			if (!vm.count("dump-disassembly")) {
 				disassembler->dumpDisassembly(std::cout);
 			}
+			delete disassembler;
+			delete engine;
 			return 0;
 		}
 
@@ -148,6 +150,11 @@
 		delete cf;
 
 		// TODO: Code generation
+		
+		VertexRange vr = boost::vertices(g);
+		for(VertexIterator v = vr.first; v != vr.second; ++v)
+			delete boost::get(boost::vertex_name, g, *v);
+		delete engine;
 	} catch (std::exception& e) {
 		std::cerr << "ERROR: " << e.what() << "\n";
 		return 3;

Modified: tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h
===================================================================
--- tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h	2010-07-05 14:46:09 UTC (rev 50679)
+++ tools/branches/gsoc2010-decompiler/decompiler/test/cfg_test.h	2010-07-05 14:51:22 UTC (rev 50680)
@@ -60,6 +60,7 @@
 			default:
 				TS_ASSERT(false);
 			}
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -93,6 +94,7 @@
 			default:
 				TS_ASSERT(false);
 			}
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -126,6 +128,7 @@
 				TS_ASSERT(false);
 				break;
 			}
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -141,6 +144,9 @@
 		c->createGroups();
 		Graph g = c->getGraph();
 		TS_ASSERT(boost::num_vertices(g) == 3);
+		VertexRange vr = boost::vertices(g);
+		for(VertexIterator v = vr.first; v != vr.second; ++v)
+			delete boost::get(boost::vertex_name, g, *v);
 		delete c;
 		delete engine;
 	}
@@ -159,6 +165,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0)
 				TS_ASSERT(gr->_type == kWhileCond);
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -178,6 +185,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 3)
 				TS_ASSERT(gr->_type == kDoWhileCond);
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -197,6 +205,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0x14)
 				TS_ASSERT(gr->_type == kBreak);
+			delete gr;
 		}
 		delete c;
 
@@ -212,6 +221,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0xA)
 				TS_ASSERT(gr->_type == kBreak);
+			delete gr;
 		}
 		delete c;
 
@@ -227,6 +237,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0xD)
 				TS_ASSERT(gr->_type == kBreak);
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -248,6 +259,7 @@
 				TS_ASSERT(gr->_type == kContinue);
 			if (gr->_start->_address == 0x1a)
 				TS_ASSERT(gr->_type == kNormal);
+			delete gr;
 		}
 		delete c;
 
@@ -263,6 +275,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0xA)
 				TS_ASSERT(gr->_type == kContinue);
+			delete gr;
 		}
 		delete c;
 
@@ -278,6 +291,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0xD)
 				TS_ASSERT(gr->_type == kContinue);
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -297,6 +311,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0x0)
 				TS_ASSERT(gr->_type == kIfCond);
+			delete gr;
 		}
 		delete c;
 
@@ -312,6 +327,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0x0)
 				TS_ASSERT(gr->_type == kIfCond);
+			delete gr;
 		}
 		delete c;
 
@@ -327,6 +343,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0x3)
 				TS_ASSERT(gr->_type == kIfCond);
+			delete gr;
 		}
 		delete c;
 
@@ -342,6 +359,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0x0)
 				TS_ASSERT(gr->_type == kIfCond);
+			delete gr;
 		}
 		delete c;
 
@@ -357,6 +375,7 @@
 			Group *gr = GET(*it);
 			if (gr->_start->_address == 0x3)
 				TS_ASSERT(gr->_type == kIfCond);
+			delete gr;
 		}
 		delete c;
 		delete engine;
@@ -378,6 +397,7 @@
 				TS_ASSERT(gr->_type == kWhileCond);
 			if (gr->_start->_address == 0xd)
 				TS_ASSERT(gr->_type == kDoWhileCond);
+			delete gr;
 		}
 		delete c;
 
@@ -395,6 +415,7 @@
 				TS_ASSERT(gr->_type == kDoWhileCond);
 			if (gr->_start->_address == 0x10)
 				TS_ASSERT(gr->_type == kDoWhileCond);
+			delete gr;
 		}
 		delete c;
 
@@ -412,6 +433,7 @@
 				TS_ASSERT(gr->_type == kWhileCond);
 			if (gr->_start->_address == 0xa)
 				TS_ASSERT(gr->_type == kWhileCond);
+			delete gr;
 		}
 		delete c;
 
@@ -429,6 +451,7 @@
 				TS_ASSERT(gr->_type == kWhileCond);
 			if (gr->_start->_address == 0xd)
 				TS_ASSERT(gr->_type == kWhileCond);
+			delete gr;
 		}
 		delete c;
 
@@ -446,6 +469,7 @@
 				TS_ASSERT(gr->_type == kWhileCond);
 			if (gr->_start->_address == 0x10)
 				TS_ASSERT(gr->_type == kDoWhileCond);
+			delete gr;
 		}
 		delete c;
 
@@ -463,6 +487,7 @@
 				TS_ASSERT(gr->_type == kWhileCond);
 			if (gr->_start->_address == 0x13)
 				TS_ASSERT(gr->_type == kDoWhileCond);
+			delete gr;
 		}
 		delete c;
 
@@ -520,6 +545,7 @@
 				TS_ASSERT(!gr->_endElse);
 				break;
 			}
+			delete gr;
 		}
 		delete c;
 		delete engine;


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list