[MPlayer-dev-eng] [Patch] codec-cfg.c codec-cfg.h Memory Free function Fix
Wei Jiang
jiangw98 at yahoo.com
Sat Oct 23 23:14:01 CEST 2004
Tested on pre5 xbmc project
wei jiang
diff -u -r1.70 codec-cfg.h
--- codec-cfg.h 9 Oct 2004 07:38:45 -0000 1.70
+++ codec-cfg.h 23 Oct 2004 21:10:11 -0000
@@ -65,5 +65,6 @@
void select_codec(char* codecname,int audioflag);
void list_codecs(int audioflag);
void codecs_reset_selection(int audioflag);
+void codecs_uninit_free();
#endif
diff -u -r1.111 codec-cfg.c
--- codec-cfg.c 12 Oct 2004 11:29:20 -0000 1.111
+++ codec-cfg.c 23 Oct 2004 21:07:52 -0000
@@ -487,11 +487,7 @@
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_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,51 @@
goto err_out_print_linenum;
}
+static void audio_codecs_uninit_free() {
+ int i;
+ for ( i = 0; i < nr_acodecs; i++)
+ if ( (audio_codecs[i]).name ) {
+ if( (audio_codecs[i]).name )
+ free((audio_codecs[i]).name);
+ if( (audio_codecs[i]).info )
+ free((audio_codecs[i]).info);
+ if( (audio_codecs[i]).comment )
+ free((audio_codecs[i]).comment);
+ if( (audio_codecs[i]).dll )
+ free((audio_codecs[i]).dll);
+ if( (audio_codecs[i]).drv )
+ free((audio_codecs[i]).drv);
+ }
+ if (audio_codecs)
+ free(audio_codecs);
+ audio_codecs=NULL;
+}
+
+static void video_codecs_uninit_free() {
+ int i;
+ for ( i = 0; i < nr_vcodecs; i++)
+ if ( (video_codecs[i]).name ) {
+ if( (video_codecs[i]).name )
+ free((video_codecs[i]).name);
+ if( (video_codecs[i]).info )
+ free((video_codecs[i]).info);
+ if( (video_codecs[i]).comment )
+ free((video_codecs[i]).comment);
+ if( (video_codecs[i]).dll )
+ free((video_codecs[i]).dll);
+ if( (video_codecs[i]).drv )
+ free((video_codecs[i]).drv);
+ }
+ if (video_codecs)
+ free(video_codecs);
+ video_codecs=NULL;
+}
+
+void codecs_uninit_free() {
+ audio_codecs_uninit_free();
+ video_codecs_uninit_free();
+}
+
codecs_t *find_audio_codec(unsigned int fourcc, unsigned int *fourccmap,
codecs_t *start)
{
_______________________________
Do you Yahoo!?
Declare Yourself - Register online to vote today!
http://vote.yahoo.com
More information about the MPlayer-dev-eng
mailing list