[MPlayer-dev-eng] [PATCH] avoid code duplication in demux_{mov, ts, ogg}

Dominik 'Rathann' Mierzejewski dominik at rangers.eu.org
Sat May 13 23:08:49 CEST 2006


Quick&dirty patch to move the realloc_struct code to a common place.
Fixes code duplication and a warning in demux_ogg. A better place
would probably be libavutil or maybe osdep/?

-- 
MPlayer developer and RPMs maintainer: http://rpm.greysector.net/mplayer/
There should be a science of discontent. People need hard times and
oppression to develop psychic muscles.
	-- from "Collected Sayings of Muad'Dib" by the Princess Irulan
-------------- next part --------------
--- MPlayer-20060513/libmpdemux/demux_mov.c.warn	2006-05-13 01:46:03.000000000 +0200
+++ MPlayer-20060513/libmpdemux/demux_mov.c	2006-05-13 22:57:26.000000000 +0200
@@ -149,12 +149,6 @@
 #define SIZE_MAX ((size_t)-1)
 #endif
 
-void *realloc_struct(void *ptr, size_t nmemb, size_t size) {
-  if (nmemb > SIZE_MAX / size)
-    return NULL;
-  return realloc(ptr, nmemb * size);
-}
-
 void mov_build_index(mov_track_t* trak,int timescale){
     int i,j,s;
     int last=trak->chunks_size;
--- MPlayer-20060513/libmpdemux/demuxer.c.warn	2006-05-13 01:46:03.000000000 +0200
+++ MPlayer-20060513/libmpdemux/demuxer.c	2006-05-13 22:56:50.000000000 +0200
@@ -1021,3 +1021,9 @@
       index = demuxer->audio->id;
     return index;
 }
+
+void *realloc_struct(void *ptr, size_t nmemb, size_t size) {
+  if (nmemb > SIZE_MAX / size)
+    return NULL;
+  return realloc(ptr, nmemb * size);
+}
--- MPlayer-20060513/libmpdemux/demuxer.h.warn	2006-04-30 22:53:41.000000000 +0200
+++ MPlayer-20060513/libmpdemux/demuxer.h	2006-05-13 22:57:06.000000000 +0200
@@ -337,3 +337,5 @@
 
 extern void demuxer_help(void);
 extern int get_demuxer_type_from_name(char *demuxer_name, int *force);
+
+extern void *realloc_struct(void *ptr, size_t nmemb, size_t size);
--- MPlayer-20060513/libmpdemux/demux_ts.c.warn	2006-05-13 21:41:33.000000000 +0200
+++ MPlayer-20060513/libmpdemux/demux_ts.c	2006-05-13 22:57:43.000000000 +0200
@@ -235,13 +235,6 @@
 #define IS_AUDIO(x) (((x) == AUDIO_MP2) || ((x) == AUDIO_A52) || ((x) == AUDIO_LPCM_BE) || ((x) == AUDIO_AAC))
 #define IS_VIDEO(x) (((x) == VIDEO_MPEG1) || ((x) == VIDEO_MPEG2) || ((x) == VIDEO_MPEG4) || ((x) == VIDEO_H264) || ((x) == VIDEO_AVC))
 
-static void *realloc_struct(void *ptr, size_t nmemb, size_t size)
-{
-	if (nmemb > SIZE_MAX / size)
-		return NULL;
-	return realloc(ptr, nmemb * size);
-}
-
 static int ts_parse(demuxer_t *demuxer, ES_stream_t *es, unsigned char *packet, int probe);
 
 static uint8_t get_packet_size(const unsigned char *buf, int size)


More information about the MPlayer-dev-eng mailing list