Memory Free function Fix, based on patch by Wei Jiang <jiangw98@yahoo.com>

git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@13808 b3059339-0415-0410-9bf9-f77b7e298cf2
This commit is contained in:
faust3 2004-10-30 10:09:52 +00:00
parent bf90e11955
commit b4918b7bae
2 changed files with 29 additions and 11 deletions

View File

@ -487,11 +487,7 @@ int parse_codec_cfg(char *cfgfile)
int tmp, i;
// in case we call it a second time
if(video_codecs!=NULL)free(video_codecs);
video_codecs=NULL;
if(audio_codecs!=NULL)free(audio_codecs);
audio_codecs=NULL;
codecs_uninit_free();
nr_vcodecs = 0;
nr_acodecs = 0;
@ -715,12 +711,7 @@ err_out_parse_error:
err_out_print_linenum:
PRINT_LINENUM;
err_out:
if (audio_codecs)
free(audio_codecs);
if (video_codecs)
free(video_codecs);
video_codecs=NULL;
audio_codecs=NULL;
codecs_uninit_free();
free(line);
line=NULL;
@ -735,6 +726,32 @@ err_out_release_num:
goto err_out_print_linenum;
}
static void codecs_free(codecs_t* codecs,int count) {
int i;
for ( i = 0; i < count; i++)
if ( (codecs[i]).name ) {
if( (codecs[i]).name )
free((codecs[i]).name);
if( (codecs[i]).info )
free((codecs[i]).info);
if( (codecs[i]).comment )
free((codecs[i]).comment);
if( (codecs[i]).dll )
free((codecs[i]).dll);
if( (codecs[i]).drv )
free((codecs[i]).drv);
}
if (codecs)
free(codecs);
}
void codecs_uninit_free() {
codecs_free(video_codecs,nr_vcodecs);
video_codecs=NULL;
codecs_free(audio_codecs,nr_acodecs);
audio_codecs=NULL;
}
codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap,
codecs_t *start)
{

View File

@ -65,5 +65,6 @@ codecs_t* find_codec(unsigned int fourcc,unsigned int *fourccmap,codecs_t *start
void select_codec(char* codecname,int audioflag);
void list_codecs(int audioflag);
void codecs_reset_selection(int audioflag);
void codecs_uninit_free();
#endif