hi all,

i've started to run fg through valgrind. i found this to be a nice option for 
getting an overview over the code in flightgear.

i plan to prepare some patches to fix various issues reported by valgrind. 
this is the first in (i hope) a series of several patches yet to follow. i 
couldn't correct any serious issues so far (just small glitches and leaks). 
when i get to know the code in flightgear a little better, there might be 
more outcome.

this diff is against current cvs.
please apply and/or comment,


- till
Index: src/Autopilot/xmlauto.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Autopilot/xmlauto.cxx,v
retrieving revision 1.26
diff -u -3 -p -u -r1.26 xmlauto.cxx
--- src/Autopilot/xmlauto.cxx	9 Jul 2007 17:15:11 -0000	1.26
+++ src/Autopilot/xmlauto.cxx	18 Jan 2008 10:37:41 -0000
@@ -818,17 +818,13 @@ bool FGXMLAutopilot::build() {
         string name = node->getName();
         // cout << name << endl;
         if ( name == "pid-controller" ) {
-            FGXMLAutoComponent *c = new FGPIDController( node );
-            components.push_back( c );
+            components.push_back( new FGPIDController( node ) );
         } else if ( name == "pi-simple-controller" ) {
-            FGXMLAutoComponent *c = new FGPISimpleController( node );
-            components.push_back( c );
+            components.push_back( new FGPISimpleController( node ) );
         } else if ( name == "predict-simple" ) {
-            FGXMLAutoComponent *c = new FGPredictor( node );
-            components.push_back( c );
+            components.push_back( new FGPredictor( node ) );
         } else if ( name == "filter" ) {
-            FGXMLAutoComponent *c = new FGDigitalFilter( node );
-            components.push_back( c );
+            components.push_back( new FGDigitalFilter( node ) );
         } else {
             SG_LOG( SG_ALL, SG_ALERT, "Unknown top level section: " 
                     << name );
Index: src/Autopilot/xmlauto.hxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Autopilot/xmlauto.hxx,v
retrieving revision 1.14
diff -u -3 -p -u -r1.14 xmlauto.hxx
--- src/Autopilot/xmlauto.hxx	12 Jul 2006 15:11:47 -0000	1.14
+++ src/Autopilot/xmlauto.hxx	18 Jan 2008 10:37:41 -0000
@@ -52,7 +52,7 @@ SG_USING_STD(deque);
  * Base class for other autopilot components
  */
 
-class FGXMLAutoComponent {
+class FGXMLAutoComponent : public SGReferenced {
 
 protected:
 
@@ -275,7 +275,7 @@ public:
 
 protected:
 
-    typedef vector<FGXMLAutoComponent *> comp_list;
+    typedef vector<SGSharedPtr<FGXMLAutoComponent> > comp_list;
 
 private:
 
Index: src/GUI/dialog.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/GUI/dialog.cxx,v
retrieving revision 1.94
diff -u -3 -p -u -r1.94 dialog.cxx
--- src/GUI/dialog.cxx	3 Jul 2007 17:26:54 -0000	1.94
+++ src/GUI/dialog.cxx	18 Jan 2008 10:37:42 -0000
@@ -813,11 +813,11 @@ FGDialog::setColor(puObject * object, SG
     if (type == "textbox" && props->getBoolValue("editable"))
         type += "-editable";
 
-    FGColor *c = new FGColor(_gui->getColor("background"));
-    c->merge(_gui->getColor(type));
-    c->merge(props->getNode("color"));
-    if (c->isValid())
-        object->setColourScheme(c->red(), c->green(), c->blue(), c->alpha());
+    FGColor c(_gui->getColor("background"));
+    c.merge(_gui->getColor(type));
+    c.merge(props->getNode("color"));
+    if (c.isValid())
+        object->setColourScheme(c.red(), c.green(), c.blue(), c.alpha());
 
     const struct {
         int mask;
@@ -840,20 +840,20 @@ FGDialog::setColor(puObject * object, SG
 
     for (int i = 0; i < numcol; i++) {
         bool dirty = false;
-        c->clear();
-        c->setAlpha(1.0);
+        c.clear();
+        c.setAlpha(1.0);
 
-        dirty |= c->merge(_gui->getColor(type + '-' + pucol[i].name));
+        dirty |= c.merge(_gui->getColor(type + '-' + pucol[i].name));
         if (which & pucol[i].mask)
-            dirty |= c->merge(props->getNode("color"));
+            dirty |= c.merge(props->getNode("color"));
 
-        if ((pucol[i].mask == LABEL) && !c->isValid())
-            dirty |= c->merge(_gui->getColor("label"));
+        if ((pucol[i].mask == LABEL) && !c.isValid())
+            dirty |= c.merge(_gui->getColor("label"));
 
-        dirty |= c->merge(props->getNode(pucol[i].cname));
+        dirty |= c.merge(props->getNode(pucol[i].cname));
 
-        if (c->isValid() && dirty)
-            object->setColor(pucol[i].id, c->red(), c->green(), c->blue(), c->alpha());
+        if (c.isValid() && dirty)
+            object->setColor(pucol[i].id, c.red(), c.green(), c.blue(), c.alpha());
     }
 }
 
Index: src/Input/input.cxx
===================================================================
RCS file: /var/cvs/FlightGear-0.9/source/src/Input/input.cxx,v
retrieving revision 1.99
diff -u -3 -p -u -r1.99 input.cxx
--- src/Input/input.cxx	1 Dec 2007 23:37:58 -0000	1.99
+++ src/Input/input.cxx	18 Jan 2008 10:37:42 -0000
@@ -1124,6 +1124,8 @@ FGInput::mouse_mode::~mouse_mode ()
 FGInput::mouse::mouse ()
   : x(-1),
     y(-1),
+    save_x(-1),
+    save_y(-1),
     nModes(1),
     current_mode(0),
     modes(0)
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Flightgear-devel mailing list
Flightgear-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/flightgear-devel

Reply via email to