Fix memory leaks reported by valgrind.

This commit is contained in:
Jonathan Moore Liles 2008-05-06 21:32:37 -05:00
parent f927e39681
commit 9aa52f3e18
10 changed files with 26 additions and 19 deletions

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 );
} }

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() ) );

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 );
} }
} }

View File

@ -348,6 +348,9 @@ Loggable::do_this ( const char *s, bool reverse )
} }
if ( arguments )
free( arguments );
return true; return true;
} }

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 )

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 );

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();
} }

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 );
} }

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();
} }

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 );
} }