[MPlayer-dev-eng] [PATCH] avoid code duplication in demux_{mov, ts, ogg}
Dominik 'Rathann' Mierzejewski
dominik at rangers.eu.org
Sat May 13 23:50:15 CEST 2006
On Saturday, 13 May 2006 at 23:39, Nico Sabbi wrote:
> Dominik 'Rathann' Mierzejewski wrote:
>
> >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/?
> >
> >
> >
>
> it's not OS dependant and it would be unavailable without libavutil.
> Maybe a new utils.[ch] ?
OK, how about alloc.[ch]?
--
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 --------------
Index: libmpdemux/demux_mov.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_mov.c,v
retrieving revision 1.149
diff -u -r1.149 demux_mov.c
--- libmpdemux/demux_mov.c 13 May 2006 21:12:43 -0000 1.149
+++ libmpdemux/demux_mov.c 13 May 2006 21:45:54 -0000
@@ -31,6 +31,7 @@
#include "stheader.h"
#include "bswap.h"
+#include "alloc.h"
#include "qtpalette.h"
#include "parse_mp4.h" // .MP4 specific stuff
@@ -149,12 +150,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;
Index: libmpdemux/demux_ogg.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ogg.c,v
retrieving revision 1.95
diff -u -r1.95 demux_ogg.c
--- libmpdemux/demux_ogg.c 13 May 2006 06:12:25 -0000 1.95
+++ libmpdemux/demux_ogg.c 13 May 2006 21:45:54 -0000
@@ -15,6 +15,7 @@
#include "stream.h"
#include "demuxer.h"
#include "stheader.h"
+#include "alloc.h"
#define FOURCC_VORBIS mmioFOURCC('v', 'r', 'b', 's')
#define FOURCC_SPEEX mmioFOURCC('s', 'p', 'x', ' ')
Index: libmpdemux/demux_ts.c
===================================================================
RCS file: /cvsroot/mplayer/main/libmpdemux/demux_ts.c,v
retrieving revision 1.55
diff -u -r1.55 demux_ts.c
--- libmpdemux/demux_ts.c 13 May 2006 10:49:46 -0000 1.55
+++ libmpdemux/demux_ts.c 13 May 2006 21:45:59 -0000
@@ -34,6 +34,7 @@
#include "parse_es.h"
#include "stheader.h"
+#include "alloc.h"
#include "bswap.h"
#include "unrarlib.h"
#include "ms_hdr.h"
@@ -235,13 +236,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)
Index: alloc.h
===================================================================
RCS file: alloc.h
diff -N alloc.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ alloc.h 13 May 2006 21:49:19 -0000
@@ -0,0 +1,7 @@
+#ifndef __ALLOC_H__
+#define __ALLOC_H__
+
+extern void *realloc_struct(void *ptr, size_t nmemb, size_t size);
+
+#endif
+
Index: alloc.c
===================================================================
RCS file: alloc.c
diff -N alloc.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ alloc.c 13 May 2006 21:49:19 -0000
@@ -0,0 +1,5 @@
+void *realloc_struct(void *ptr, size_t nmemb, size_t size) {
+ if (nmemb > SIZE_MAX / size)
+ return NULL;
+ return realloc(ptr, nmemb * size);
+}
More information about the MPlayer-dev-eng
mailing list