Fix some memory leaks and other valgrind warnings.
This commit is contained in:
parent
a3f1265ef3
commit
0da98f95b8
|
@ -126,7 +126,7 @@ nsd.default_path( *default_path );
|
|||
nsd.run();
|
||||
|
||||
if ( nsd.default_path() )
|
||||
*default_path = strdup( nsd.default_path() );
|
||||
*default_path = nsd.default_path();
|
||||
|
||||
return nsd.path;} {}
|
||||
}
|
||||
|
|
2
lib/ntk
2
lib/ntk
|
@ -1 +1 @@
|
|||
Subproject commit 415422bd1b35cdbac5c751dcf8f4fb9cbe696927
|
||||
Subproject commit d0063527aa360a3f1fd34e76fc0dd9125efb9202
|
|
@ -176,6 +176,9 @@ Chain::~Chain ( )
|
|||
|
||||
engine()->lock();
|
||||
|
||||
for ( unsigned int i = scratch_port.size(); i--; )
|
||||
delete[] (sample_t*)scratch_port[i].buffer();
|
||||
|
||||
/* if we leave this up to FLTK, it will happen after we've
|
||||
already destroyed the engine */
|
||||
modules_pack->clear();
|
||||
|
|
|
@ -190,11 +190,11 @@ void Mixer::command_new ( void )
|
|||
{
|
||||
DMESSAGE( "New project" );
|
||||
|
||||
char *default_path;
|
||||
char *default_path = read_line( user_config_dir, "default_path" );
|
||||
|
||||
read_line( user_config_dir, "default_path", &default_path );
|
||||
|
||||
char *path = new_project_chooser( &default_path );
|
||||
char *result_path = default_path;
|
||||
|
||||
char *path = new_project_chooser( &result_path );
|
||||
|
||||
if ( path )
|
||||
{
|
||||
|
@ -207,10 +207,13 @@ void Mixer::command_new ( void )
|
|||
|
||||
update_menu();
|
||||
|
||||
if ( default_path )
|
||||
if ( result_path != default_path )
|
||||
free(default_path);
|
||||
|
||||
if ( result_path )
|
||||
{
|
||||
write_line( user_config_dir, "default_path", default_path );
|
||||
free( default_path );
|
||||
write_line( user_config_dir, "default_path", result_path );
|
||||
free( result_path );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -48,6 +48,8 @@ namespace OSC
|
|||
free( _path );
|
||||
if ( _typespec )
|
||||
free( _typespec );
|
||||
if ( _documentation )
|
||||
free( _documentation );
|
||||
}
|
||||
|
||||
/**********/
|
||||
|
@ -228,13 +230,25 @@ namespace OSC
|
|||
Endpoint::~Endpoint ( )
|
||||
{
|
||||
// lo_server_thread_free( _st );
|
||||
|
||||
for ( std::list<Method*>::iterator i = _methods.begin();
|
||||
i != _methods.end();
|
||||
i++ )
|
||||
delete(*i);
|
||||
|
||||
_methods.clear();
|
||||
|
||||
if ( _server )
|
||||
{
|
||||
lo_server_free( _server );
|
||||
_server = 0;
|
||||
}
|
||||
|
||||
lo_address_free( _addr );
|
||||
_addr = 0;
|
||||
}
|
||||
|
||||
|
||||
OSC::Signal *
|
||||
Endpoint::find_target_by_peer_address ( std::list<Signal*> *l, lo_address addr )
|
||||
{
|
||||
|
@ -947,14 +961,13 @@ namespace OSC
|
|||
Signal *
|
||||
Endpoint::add_signal ( const char *path, Signal::Direction dir, float min, float max, float default_value, signal_handler handler, void *user_data )
|
||||
{
|
||||
Signal *o = new Signal( path, dir );
|
||||
|
||||
char *s;
|
||||
asprintf( &s, "%s%s", name(), path );
|
||||
|
||||
if ( s )
|
||||
o->_path = s;
|
||||
Signal *o = new Signal( s, dir );
|
||||
|
||||
free(s);
|
||||
|
||||
o->_handler = handler;
|
||||
o->_user_data = user_data;
|
||||
o->_endpoint = this;
|
||||
|
|
|
@ -159,25 +159,27 @@ write_line ( const char *dir, const char *name, const char *value )
|
|||
}
|
||||
|
||||
/** write a single string to a file */
|
||||
void
|
||||
read_line ( const char *dir, const char *name, char **value )
|
||||
char *
|
||||
read_line ( const char *dir, const char *name )
|
||||
{
|
||||
char path[512];
|
||||
|
||||
*value = 0;
|
||||
|
||||
snprintf( path, sizeof( path ), "%s/%s", dir, name );
|
||||
|
||||
FILE *fp = fopen( path, "r" );
|
||||
|
||||
if ( ! fp )
|
||||
return;
|
||||
return 0;
|
||||
|
||||
*value = (char*)malloc( 512 );
|
||||
char *value = (char*)malloc( 512 );
|
||||
|
||||
fgets( *value, 512, fp );
|
||||
value[0] = 0;
|
||||
|
||||
fgets( value, 512, fp );
|
||||
|
||||
fclose( fp );
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
#include <sys/statvfs.h>
|
||||
|
|
|
@ -30,7 +30,7 @@ int backwards_fgetc ( FILE *fp );
|
|||
char * backwards_fgets ( char *s, int size, FILE *fp );
|
||||
void touch ( int fd );
|
||||
void write_line ( const char *dir, const char *name, const char *value );
|
||||
void read_line ( const char *dir, const char *name, char **value );
|
||||
char * read_line ( const char *dir, const char *name );
|
||||
size_t free_space ( const char *file );
|
||||
size_t total_space ( const char *file );
|
||||
int percent_used ( const char *file );
|
||||
|
|
|
@ -144,7 +144,7 @@ class NSM_Client : public Fl_Group
|
|||
|
||||
client_name->copy_label( l );
|
||||
|
||||
// _client_label = l;
|
||||
free(l);
|
||||
|
||||
redraw();
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public:
|
|||
{
|
||||
if ( _client_id )
|
||||
free( _client_id );
|
||||
|
||||
|
||||
_client_id = strdup( v );
|
||||
}
|
||||
|
||||
|
@ -240,11 +240,7 @@ public:
|
|||
void
|
||||
pending_command ( const char *command )
|
||||
{
|
||||
char *cmd = strdup( command );
|
||||
|
||||
free( (void*)_progress->label() );
|
||||
|
||||
_progress->label( cmd );
|
||||
_progress->copy_label( command );
|
||||
|
||||
stopped( 0 );
|
||||
|
||||
|
@ -375,7 +371,7 @@ public:
|
|||
{ Fl_Progress *o = _progress = new Fl_Progress( xx, Y + H * 0.25, 75, H * 0.50, NULL );
|
||||
o->box( FL_FLAT_BOX );
|
||||
o->color( FL_BLACK );
|
||||
o->label( strdup( "launch" ) );
|
||||
o->copy_label( "launch" );
|
||||
o->labelsize( 12 );
|
||||
o->minimum( 0.0f );
|
||||
o->maximum( 1.0f );
|
||||
|
@ -462,6 +458,12 @@ public:
|
|||
|
||||
~NSM_Client ( )
|
||||
{
|
||||
if ( _client_id )
|
||||
{
|
||||
free( _client_id );
|
||||
_client_id = NULL;
|
||||
}
|
||||
|
||||
if ( _client_name )
|
||||
{
|
||||
free( _client_name );
|
||||
|
@ -925,7 +927,7 @@ public:
|
|||
o->type( FL_VERTICAL );
|
||||
o->spacing( 2 );
|
||||
|
||||
{ Fl_Box *o = new Fl_Box( 0,0,100, 24, "Sessions" );
|
||||
{ new Fl_Box( 0,0,100, 24, "Sessions" );
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -1049,8 +1051,6 @@ public:
|
|||
|
||||
osc->owner = this;
|
||||
|
||||
osc->url();
|
||||
|
||||
osc->add_method( "/error", "sis", osc_handler, osc, "msg" );
|
||||
osc->add_method( "/reply", "ss", osc_handler, osc, "msg" );
|
||||
osc->add_method( "/reply", "s", osc_handler, osc, "" );
|
||||
|
@ -1398,14 +1398,13 @@ main (int argc, char **argv )
|
|||
{
|
||||
/* pass non-option arguments on to daemon */
|
||||
|
||||
char **args = (char **)malloc( 4 + argc - optind );
|
||||
char *args[4 + argc - optind];
|
||||
|
||||
int i = 0;
|
||||
args[i++] = (char*)"nsmd";
|
||||
args[i++] = (char*)"--gui-url";
|
||||
args[i++] = strdup("nsmd");
|
||||
args[i++] = strdup("--gui-url");
|
||||
args[i++] = url;
|
||||
|
||||
|
||||
for ( ; optind < argc; i++, optind++ )
|
||||
{
|
||||
DMESSAGE( "Passing argument: %s", argv[optind] );
|
||||
|
@ -1419,6 +1418,8 @@ main (int argc, char **argv )
|
|||
FATAL( "Error starting process: %s", strerror( errno ) );
|
||||
}
|
||||
}
|
||||
|
||||
free(url);
|
||||
}
|
||||
|
||||
Fl::add_timeout( 1.0, ping, NULL );
|
||||
|
|
|
@ -38,12 +38,15 @@ OSC_Thread::OSC_Thread ( )
|
|||
|
||||
OSC_Thread::~OSC_Thread ( )
|
||||
{
|
||||
lock();
|
||||
if ( _shutdown == false )
|
||||
{
|
||||
_shutdown = true;
|
||||
_thread.join();
|
||||
}
|
||||
}
|
||||
unlock();
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
OSC_Thread::start ( )
|
||||
|
|
|
@ -209,7 +209,7 @@ Project::close ( void )
|
|||
|
||||
*Project::_name = '\0';
|
||||
*Project::_created_on = '\0';
|
||||
|
||||
|
||||
release_lock( &_lockfd, ".lock" );
|
||||
|
||||
delete engine;
|
||||
|
@ -326,6 +326,9 @@ Project::open ( const char *name )
|
|||
else
|
||||
*_created_on = 0;
|
||||
|
||||
free( created_by );
|
||||
free( creation_date );
|
||||
|
||||
set_name( name );
|
||||
|
||||
*_path = '\0';
|
||||
|
|
|
@ -330,12 +330,13 @@ pi.run();}
|
|||
label {&New}
|
||||
callback {save_timeline_settings();
|
||||
|
||||
|
||||
char *result_path;
|
||||
|
||||
char *default_path;
|
||||
char *default_path = read_line( user_config_dir, "default_path" );
|
||||
result_path = default_path;
|
||||
|
||||
read_line( user_config_dir, "default_path", &default_path );
|
||||
|
||||
char *path = new_project_chooser( &default_path );
|
||||
char *path = new_project_chooser( &result_path );
|
||||
|
||||
if ( path )
|
||||
{
|
||||
|
@ -344,10 +345,13 @@ char *default_path;
|
|||
free( path );
|
||||
}
|
||||
|
||||
if ( default_path )
|
||||
if ( reuslt_path != default_path )
|
||||
free(default_path);
|
||||
|
||||
if ( result_path )
|
||||
{
|
||||
write_line( user_config_dir, "default_path", default_path );
|
||||
free( default_path );
|
||||
write_line( user_config_dir, "default_path", result_path );
|
||||
free( result_path );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -395,6 +395,8 @@ Timeline::menu_cb ( Fl_Menu_ *m )
|
|||
|
||||
Track *t = new Track( name );
|
||||
|
||||
free( name );
|
||||
|
||||
Audio_Sequence *o = new Audio_Sequence( t );
|
||||
|
||||
add_track( t );
|
||||
|
@ -582,6 +584,8 @@ Timeline::~Timeline ( )
|
|||
{
|
||||
delete osc_thread;
|
||||
osc_thread = 0;
|
||||
delete osc;
|
||||
osc = 0;
|
||||
}
|
||||
|
||||
Timeline::Timeline ( int X, int Y, int W, int H, const char* L ) : BASE( X, Y, W, H, L )
|
||||
|
@ -2095,7 +2099,9 @@ Timeline::init_osc ( const char *osc_port )
|
|||
|
||||
osc->owner = this;
|
||||
|
||||
printf( "OSC=%s\n", osc->url() );
|
||||
char *url = osc->url();
|
||||
printf( "OSC=%s\n", url );
|
||||
free(url);
|
||||
|
||||
osc->add_method( "/non/hello", "ssss", &Timeline::osc_non_hello, osc, "" );
|
||||
|
||||
|
|
Loading…
Reference in New Issue