Browse Source

Fix memory leaks reported by valgrind.

tags/non-daw-v1.1.0
Jonathan Moore Liles 17 years ago
parent
commit
9aa52f3e18
10 changed files with 26 additions and 19 deletions
  1. +0
    -12
      Timeline/Annotation_Point.H
  2. +3
    -1
      Timeline/Audio_Sequence.C
  3. +1
    -1
      Timeline/Control_Sequence.C
  4. +3
    -0
      Timeline/Loggable.C
  5. +2
    -1
      Timeline/Sequence.C
  6. +11
    -0
      Timeline/Sequence_Point.H
  7. +0
    -1
      Timeline/Tempo_Point.C
  8. +1
    -1
      Timeline/Tempo_Point.H
  9. +1
    -2
      Timeline/Time_Point.H
  10. +4
    -0
      Timeline/Track.C

+ 0
- 12
Timeline/Annotation_Point.H View File

@@ -27,17 +27,6 @@
class Annotation_Point : public Sequence_Point class Annotation_Point : public Sequence_Point
{ {


public:

const char *name ( void ) const { return _label; }
void name ( const char *s )
{
if ( _label )
free( _label );
_label = strdup( s );
redraw();
}

protected: protected:


// const char *class_name ( void ) { return "Annotation_Point"; } // const char *class_name ( void ) { return "Annotation_Point"; }
@@ -101,7 +90,6 @@ public:
~Annotation_Point ( ) ~Annotation_Point ( )
{ {
log_destroy(); log_destroy();
if ( _label ) free( _label );
} }






+ 3
- 1
Timeline/Audio_Sequence.C View File

@@ -81,7 +81,7 @@ Audio_Sequence::set ( Log_Entry &e )
t->track( this ); t->track( this );
} }
else if ( ! strcmp( ":n", s ) ) else if ( ! strcmp( ":n", s ) )
name( strdup( v ) );
name( v );
} }
} }


@@ -238,6 +238,8 @@ Audio_Sequence::handle ( int m )
return 0; return 0;
} }


free( file );

// Audio_Region *r = // Audio_Region *r =
new Audio_Region( c, this, timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ) ); new Audio_Region( c, this, timeline->xoffset + timeline->x_to_ts( Fl::event_x() - x() ) );




+ 1
- 1
Timeline/Control_Sequence.C View File

@@ -86,7 +86,7 @@ Control_Sequence::set ( Log_Entry &e )
t->add( this ); t->add( this );
} }
else if ( ! strcmp( ":n", s ) ) else if ( ! strcmp( ":n", s ) )
name( strdup( v ) );
name( v );


} }
} }


+ 3
- 0
Timeline/Loggable.C View File

@@ -348,6 +348,9 @@ Loggable::do_this ( const char *s, bool reverse )


} }


if ( arguments )
free( arguments );

return true; return true;
} }




+ 2
- 1
Timeline/Sequence.C View File

@@ -58,7 +58,8 @@ Sequence::init ( void )


Sequence::~Sequence ( ) Sequence::~Sequence ( )
{ {
/* FIXME: what to do with regions? */
if ( _name )
free( _name );


for ( std::list <Sequence_Widget*>::iterator i = _widgets.begin(); for ( std::list <Sequence_Widget*>::iterator i = _widgets.begin();
i != _widgets.end(); ++i ) i != _widgets.end(); ++i )


+ 11
- 0
Timeline/Sequence_Point.H View File

@@ -33,6 +33,15 @@ protected:


public: public:


const char *name ( void ) const { return _label; }
void name ( const char *s )
{
if ( _label )
free( _label );
_label = strdup( s );
redraw();
}

Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; } Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; }
virtual int abs_w ( void ) const { return 8; } virtual int abs_w ( void ) const { return 8; }


@@ -63,6 +72,8 @@ public:


virtual ~Sequence_Point ( ) virtual ~Sequence_Point ( )
{ {
if ( _label )
free( _label );
} }


virtual void draw_box ( void ); virtual void draw_box ( void );


+ 0
- 1
Timeline/Tempo_Point.C View File

@@ -67,7 +67,6 @@ Tempo_Point::Tempo_Point ( nframes_t when, float bpm )


Tempo_Point::~Tempo_Point ( ) Tempo_Point::~Tempo_Point ( )
{ {
if ( _label ) delete[] _label;
log_destroy(); log_destroy();
} }




+ 1
- 1
Timeline/Tempo_Point.H View File

@@ -30,7 +30,7 @@ class Tempo_Point : public Sequence_Point
_make_label ( void ) _make_label ( void )
{ {
if ( ! _label ) if ( ! _label )
_label = new char[40];
_label = (char*)malloc( 40 );


snprintf( _label, 40, "%.1f", _tempo ); snprintf( _label, 40, "%.1f", _tempo );
} }


+ 1
- 2
Timeline/Time_Point.H View File

@@ -51,7 +51,7 @@ class Time_Point : public Sequence_Point
_make_label ( void ) _make_label ( void )
{ {
if ( ! _label ) if ( ! _label )
_label = new char[40];
_label = (char*)malloc( 40 );


snprintf( _label, 40, "%d/%d", _time.beats_per_bar, _time.beat_type ); snprintf( _label, 40, "%d/%d", _time.beats_per_bar, _time.beat_type );
} }
@@ -94,7 +94,6 @@ public:


~Time_Point ( ) ~Time_Point ( )
{ {
if ( _label ) delete[] _label;
log_destroy(); log_destroy();
} }




+ 4
- 0
Timeline/Track.C View File

@@ -259,10 +259,14 @@ Track::~Track ( )
for ( int i = control_out.size(); i--; ) for ( int i = control_out.size(); i--; )
{ {
control_out.back()->shutdown(); control_out.back()->shutdown();
delete control_out.back();
control_out.pop_back(); control_out.pop_back();
} }


log_destroy(); log_destroy();

if ( _name )
free( _name );
} }






Loading…
Cancel
Save