comparison gui/interface.c @ 32712:6ff3cc81d602

Fix resource leaks and check for realloc failures (reported by cppcheck)
author ib
date Wed, 19 Jan 2011 22:02:58 +0000
parents 18338ee51c9d
children 12ae3b893c59
comparison
equal deleted inserted replaced
32711:ebb1c06a639d 32712:6ff3cc81d602
439 439
440 } 440 }
441 441
442 static void add_vf( char * str ) 442 static void add_vf( char * str )
443 { 443 {
444 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_AddingVideoFilter,str ); 444 void *p;
445
445 if ( vf_settings ) 446 if ( vf_settings )
446 { 447 {
447 int i = 0; 448 int i = 0;
448 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { i=-1; break; } 449 while ( vf_settings[i].name ) if ( !gstrcmp( vf_settings[i++].name,str ) ) { i=-1; break; }
449 if ( i != -1 ) 450 if ( i != -1 )
450 { vf_settings=realloc( vf_settings,( i + 2 ) * sizeof( m_obj_settings_t ) ); vf_settings[i].name=strdup( str );vf_settings[i].attribs = NULL; vf_settings[i+1].name=NULL; } 451 {
451 } else { vf_settings=malloc( 2 * sizeof( m_obj_settings_t ) ); vf_settings[0].name=strdup( str );vf_settings[0].attribs = NULL; vf_settings[1].name=NULL; } 452 if ( !( p=realloc( vf_settings,( i + 2 ) * sizeof( m_obj_settings_t ) ) ) ) return;
453 vf_settings=p;
454 vf_settings[i].name=strdup( str );
455 vf_settings[i].attribs = NULL;
456 vf_settings[i+1].name=NULL;
457 }
458 }
459 else { vf_settings=malloc( 2 * sizeof( m_obj_settings_t ) ); vf_settings[0].name=strdup( str );vf_settings[0].attribs = NULL; vf_settings[1].name=NULL; }
460
461 mp_msg( MSGT_GPLAYER,MSGL_STATUS,MSGTR_AddingVideoFilter,str );
452 } 462 }
453 463
454 static void remove_vf( char * str ) 464 static void remove_vf( char * str )
455 { 465 {
456 int n = 0; 466 int n = 0;