More fix for memory leaks in the Freestyle module.
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Wed, 15 May 2013 01:30:03 +0000 (01:30 +0000)
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>
Wed, 15 May 2013 01:30:03 +0000 (01:30 +0000)
source/blender/freestyle/intern/application/Controller.cpp
source/blender/freestyle/intern/geometry/FitCurve.cpp
source/blender/freestyle/intern/system/PseudoNoise.cpp
source/blender/freestyle/intern/system/PseudoNoise.h
source/blender/freestyle/intern/system/TimeStamp.cpp
source/blender/freestyle/intern/system/TimeStamp.h

index 7303ccc95f3bb393081d55d87e93d519ba2a6466..436cdbfe6b5a3b1b2e903153f6a3d38ea5587326 100644 (file)
@@ -165,6 +165,11 @@ Controller::~Controller()
                _inter = NULL;
        }
 
+       if (_ProgressBar) {
+               delete _ProgressBar;
+               _ProgressBar = NULL;
+       }
+
        //delete _current_dirs;
 }
 
index c043f2cb0b944c0204e8deec54fa12c559e05743..cc21ba05f3d27060290a356f0887c1bbe9c3312a 100644 (file)
@@ -487,6 +487,8 @@ void FitCurveWrapper::FitCurve(vector<Vec2d>& data, vector<Vec2d>& oCurve, doubl
 
        FitCurve(d, size, error);
 
+       delete[] d;
+
        // copy results
        for (vector<Vector2>::iterator v = _vertices.begin(), vend = _vertices.end(); v != vend; ++v) {
                oCurve.push_back(Vec2d(v->x(), v->y())) ;
index 77b7c56527985064928be8144629e1f3a30fbddc..b70564d147c40e5d0ea4215cf0cbcb30e91796b0 100644 (file)
 
 namespace Freestyle {
 
-static const unsigned NB_VALUE_NOISE = 512;
-
-real *PseudoNoise::_values;
+real PseudoNoise::_values[];
 
 PseudoNoise::PseudoNoise() {}
 
 void PseudoNoise::init(long seed)
 {
-       _values = new real[NB_VALUE_NOISE];
        RandGen::srand48(seed);
        for (unsigned int i = 0; i < NB_VALUE_NOISE; i++)
                _values[i] = -1.0 + 2.0 * RandGen::drand48();
index 302b305325f33670028de985149fd686aa6f4ae6..ce725723b592a467cebcfdb6e9797c50d697d148 100644 (file)
@@ -53,7 +53,8 @@ public:
        static void init(long seed);
 
 protected:
-       static real *_values;
+       static const unsigned NB_VALUE_NOISE = 512;
+       static real _values[NB_VALUE_NOISE];
 
 #ifdef WITH_CXX_GUARDEDALLOC
 public:
index dc4e717486d427f2a8b620f946881d3b351e7231..7c02095ad51382cde56290d4c54dd200001f060a 100644 (file)
@@ -30,6 +30,6 @@
 namespace Freestyle {
 
 LIB_SYSTEM_EXPORT
-TimeStamp *TimeStamp::_instance = 0;
+TimeStamp TimeStamp::_instance;
 
 } /* namespace Freestyle */
index 88063280363a62d0f3df13c2df8124be061c2e28..052816c5a8586c53108e66525ce0c4c0f0725189 100644 (file)
@@ -41,9 +41,7 @@ class LIB_SYSTEM_EXPORT TimeStamp
 public:
        static inline TimeStamp *instance()
        {
-               if (_instance == NULL)
-                       _instance = new TimeStamp;
-               return _instance;
+               return &_instance;
        }
 
        inline unsigned getTimeStamp() const
@@ -70,7 +68,7 @@ protected:
        TimeStamp(const TimeStamp&) {}
 
 private:
-       static TimeStamp *_instance;
+       static TimeStamp _instance;
        unsigned _time_stamp;
 
 #ifdef WITH_CXX_GUARDEDALLOC