From 65df570a30637acc63adc5134dc048400539e552 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Tue, 12 Feb 2008 19:37:26 -0600 Subject: [PATCH] Clean up some uninitialized values flagged by valgrind. --- canvas.C | 5 +- grid.C | 1 + gui/event_edit.fl | 12 +++-- gui/ui.fl | 130 +++++++++++++++++++++++----------------------- instrument.C | 2 +- sequence.C | 5 +- 6 files changed, 83 insertions(+), 72 deletions(-) diff --git a/canvas.C b/canvas.C index 93feb9d..683c4d8 100644 --- a/canvas.C +++ b/canvas.C @@ -63,10 +63,11 @@ Canvas::_alloc_array ( void ) Canvas::Canvas ( ) { - m.height = m.width = m.div_w = m.div_h = m.playhead = m.margin_top = m.margin_left = m.playhead = m.w = m.h = m.p1 = m.p2 = 0; + m.origin_x = m.origin_y = m.height = m.width = m.div_w = m.div_h = m.playhead = m.margin_top = m.margin_left = m.playhead = m.w = m.h = m.p1 = m.p2 = 0; m.margin_top = ruler_height; + m.draw = false; m.ruler_drawn = false; m.mapping_drawn = false; m.grid_drawn = false; @@ -269,7 +270,7 @@ Canvas::copy ( void ) void Canvas::_reset ( void ) { - cell_t empty; + cell_t empty = {0,0,0,0}; for ( uint y = m.vp->h; y-- ; ) for ( uint x = m.vp->w; x-- ; ) diff --git a/grid.C b/grid.C index 05a46de..142c01b 100644 --- a/grid.C +++ b/grid.C @@ -51,6 +51,7 @@ Grid::Grid ( void ) viewport.x = 0; viewport.y = 0; + _playing = false; _start = _end = _index = 0; } diff --git a/gui/event_edit.fl b/gui/event_edit.fl index cb11be9..91ec076 100644 --- a/gui/event_edit.fl +++ b/gui/event_edit.fl @@ -48,7 +48,11 @@ _grid->events( _old ); delete _old; -delete window;} open +_el = _old = NULL; + +o->hide(); + +Fl::delete_widget( o );} open selected xywh {704 82 659 803} type Double box DOWN_BOX resizable code0 {\#include "event_edit.H"} code1 {\#include "../grid.H"} @@ -244,8 +248,7 @@ else { scroll_bar->hide(); scroll_w->size( scroll_w->parent()->w(), scroll_w->parent()->h() ); -}} {selected - } +}} {} } Function {scroll( int y )} {open return_type void } { @@ -291,6 +294,7 @@ while( w->shown() ) widget_class Event_Widget {user_data_type {void *} open xywh {969 357 594 31} type Single code0 {\#include "../event.H"} + code1 {_event = NULL;} class Fl_Group size_range {400 24 0 24} visible } { decl {static const Fl_Color note_color = FL_BLACK;} {} @@ -326,6 +330,8 @@ for ( int i = 2; i < children(); i++ ) Fl_Valuator *d1, *d2; +d1 = d2 = NULL; + name->color( FL_BLACK ); name->value( e->selected() ); diff --git a/gui/ui.fl b/gui/ui.fl index 3077dd3..93366a4 100644 --- a/gui/ui.fl +++ b/gui/ui.fl @@ -1388,8 +1388,7 @@ if ( _c ) } -// Fl_Window::resize( x, y, w, h );} {selected - } +// Fl_Window::resize( x, y, w, h );} {} } Function {draw()} {open return_type void } { @@ -1505,6 +1504,66 @@ _border_drawn = true;} {} } } +class Instrument_Editor {} { + Function {Instrument_Editor()} {open return_type void + } { + code {make_window();} {} + } + decl {Instrument *_inst;} {} + decl {int _note;} {} + Function {make_window()} {open + } { + Fl_Window window { + label {Instrument Editor} + callback {done->do_callback();} open + xywh {670 458 339 191} type Double visible + } { + Fl_Box {} { + label {Instrument Row} + xywh {8 15 321 28} box ROUNDED_BOX color 94 labelsize 22 labelcolor 39 + } + Fl_Input name_field { + label Name + callback {_inst->note_name( _note, strdup( o->value() ) );} + xywh {10 70 321 25} selection_color 48 align 1 when 1 textcolor 32 + } + Fl_Value_Slider volume_slider { + label {Volume %} + callback {_inst->velocity( _note, o->value() );} + xywh {10 112 321 27} type Horizontal align 1 maximum 100 step 1 textsize 14 + } + Fl_Value_Output note_field { + label {Note:} + xywh {52 158 43 24} + } + Fl_Return_Button done { + label Done + callback {if ( _inst ) + _inst->save(); + +window->hide();} + xywh {255 157 76 25} + } + } + } + Function {set( Instrument *i, int n )} {open return_type void + } { + code {_inst = i; +_note = n; + +volume_slider->value( i->velocity( n ) ); +name_field->value( i->note_name( n ) ); +note_field->value( n );} {} + } + Function {run()} {open return_type void + } { + code {window->show(); + +while ( window->shown() ) + Fl::wait();} {} + } +} + class Trigger {: {public Fl_Dial} } { Function {Trigger( int X, int Y, int W, int H, const char *L = 0 ) : Fl_Dial( X, Y, W, H, L )} {open @@ -1574,67 +1633,7 @@ return r;} {} } } -class Instrument_Editor {} { - Function {Instrument_Editor()} {open return_type void - } { - code {make_window();} {} - } - decl {Instrument *_inst;} {} - decl {int _note;} {} - Function {make_window()} {open - } { - Fl_Window window { - label {Instrument Editor} - callback {done->do_callback();} open - xywh {670 458 339 191} type Double visible - } { - Fl_Box {} { - label {Instrument Row} - xywh {8 15 321 28} box ROUNDED_BOX color 94 labelsize 22 labelcolor 39 - } - Fl_Input name_field { - label Name - callback {_inst->note_name( _note, strdup( o->value() ) );} - xywh {10 70 321 25} selection_color 48 align 1 when 1 textcolor 32 - } - Fl_Value_Slider volume_slider { - label {Volume %} - callback {_inst->velocity( _note, o->value() );} - xywh {10 112 321 27} type Horizontal align 1 maximum 100 step 1 textsize 14 - } - Fl_Value_Output note_field { - label {Note:} - xywh {52 158 43 24} - } - Fl_Return_Button done { - label Done - callback {if ( _inst ) - _inst->save(); - -window->hide();} - xywh {255 157 76 25} - } - } - } - Function {set( Instrument *i, int n )} {open return_type void - } { - code {_inst = i; -_note = n; - -volume_slider->value( i->velocity( n ) ); -name_field->value( i->note_name( n ) ); -note_field->value( n );} {} - } - Function {run()} {open return_type void - } { - code {window->show(); - -while ( window->shown() ) - Fl::wait();} {} - } -} - -widget_class Triggers { +widget_class Triggers {open xywh {121 31 1278 1003} type Double hide resizable code0 {populate();} code1 {\#include } @@ -1717,7 +1716,7 @@ for ( i = 0; i < MAX_PATTERN; i++ ) { b->color( fl_lighter( FL_GRAY ) ); - Fl_Color c; + Fl_Color c = FL_BLUE; switch ( p->mode() ) { @@ -1741,7 +1740,8 @@ for ( i = 0; i < MAX_PATTERN; i++ ) b->value( 0 ); } -}} {} +}} {selected + } } Function {resize( int X, int Y, int W, int H )} {open return_type void } { diff --git a/instrument.C b/instrument.C index be01175..62f636e 100644 --- a/instrument.C +++ b/instrument.C @@ -291,7 +291,7 @@ Instrument::listing ( void ) delete sys; - char **sa = (char**)malloc( usr->size() * sizeof( char * ) + 1 ); + char **sa = (char**)malloc( (usr->size() + 1) * sizeof( char * ) ); int i = 0; for ( list ::iterator s = usr->begin(); s != usr->end(); s++, i++ ) diff --git a/sequence.C b/sequence.C index 100bd34..9043d0b 100644 --- a/sequence.C +++ b/sequence.C @@ -31,7 +31,10 @@ sequence::sequence ( void ) { _rd = new data; - _notes = NULL; + _name = _notes = NULL; + + _index = 0; + _playing = 0; }