diff options
author | reimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2010-09-12 11:44:42 +0000 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2010-11-02 04:16:46 +0200 |
commit | fe6c4fcae203e6f95ae654acf80f912185c853da (patch) | |
tree | 22f073c1bcb6888cadb0ca3ce351d5eb6b06b9fd /libmpdemux/demux_real.c | |
parent | fcdeaadeaebdddcb2d743ecdafacea36e7260e36 (diff) | |
download | mpv-fe6c4fcae203e6f95ae654acf80f912185c853da.tar.bz2 mpv-fe6c4fcae203e6f95ae654acf80f912185c853da.tar.xz |
cleanup: malloc+memset->calloc, sizeof(TYPE)->sizeof(*ptr)
Replace malloc+memset by calloc
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32181 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32182 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32183 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace some sizeof(type) by sizeof(*pointer)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32184 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32186 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32187 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32188 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace sizoef(type) by sizeof(*ptrvar).
Besides being consistent with FFmpeg style,
this reduces the size of a patch to rename these
types to not conflict with the windows.h definitions.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32189 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32191 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32192 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace sizeof(type) by sizeof(*ptrvar)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32193 b3059339-0415-0410-9bf9-f77b7e298cf2
Remove a useless cast.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32194 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace sizeof(type)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32195 b3059339-0415-0410-9bf9-f77b7e298cf2
Remove a useless cast.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32196 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace several sizeof(WAVEFORMATEX)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32197 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace one more instance of sizeof(WAVEFORMATEX); fix compilation.
patch by Clément Bœsch, ubitux gmail com
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32199 b3059339-0415-0410-9bf9-f77b7e298cf2
Avoid some pointless uses of sizeof() and one related cast.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32200 b3059339-0415-0410-9bf9-f77b7e298cf2
Merge one malloc() + memset() invocation into calloc().
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32202 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32203 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace sizeof(WAVEFORMATEX) occurrences.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32205 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace malloc+memset by calloc.
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32206 b3059339-0415-0410-9bf9-f77b7e298cf2
Replace sizeof(BITMAPINFOHEADER)
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@32207 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux/demux_real.c')
-rw-r--r-- | libmpdemux/demux_real.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/libmpdemux/demux_real.c b/libmpdemux/demux_real.c index 4d95311726..80180b8a41 100644 --- a/libmpdemux/demux_real.c +++ b/libmpdemux/demux_real.c @@ -474,8 +474,7 @@ static int real_check_file(demuxer_t* demuxer) if (c != MKTAG('.', 'R', 'M', 'F')) return 0; /* bad magic */ - priv = malloc(sizeof(real_priv_t)); - memset(priv, 0, sizeof(real_priv_t)); + priv = calloc(1, sizeof(real_priv_t)); demuxer->priv = priv; return DEMUXER_TYPE_REAL; @@ -784,7 +783,7 @@ got_audio: if (++(priv->sub_packet_cnt) < sph) audioreorder_getnextpk = 1; else { - int apk_usize = ((WAVEFORMATEX*)((sh_audio_t*)ds->sh)->wf)->nBlockAlign; + int apk_usize = ((sh_audio_t*)ds->sh)->wf->nBlockAlign; audioreorder_getnextpk = 0; priv->sub_packet_cnt = 0; // Release all the audio packets @@ -1373,8 +1372,7 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer) } /* Emulate WAVEFORMATEX struct: */ - sh->wf = malloc(sizeof(WAVEFORMATEX)); - memset(sh->wf, 0, sizeof(WAVEFORMATEX)); + sh->wf = calloc(1, sizeof(*sh->wf)); sh->wf->nChannels = sh->channels; sh->wf->wBitsPerSample = sh->samplesize*8; sh->wf->nSamplesPerSec = sh->samplerate; @@ -1411,7 +1409,7 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer) goto skip_this_chunk; } sh->wf->cbSize = codecdata_length; - sh->wf = realloc(sh->wf, sizeof(WAVEFORMATEX)+sh->wf->cbSize); + sh->wf = realloc(sh->wf, sizeof(*sh->wf)+sh->wf->cbSize); stream_read(demuxer->stream, ((char*)(sh->wf+1)), codecdata_length); // extras if (priv->intl_id[stream_id] == MKTAG('g', 'e', 'n', 'r')) sh->wf->nBlockAlign = sub_packet_size; @@ -1479,8 +1477,7 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer) mp_tmsg(MSGT_DEMUX, MSGL_INFO, "[%s] Audio stream found, -aid %d\n", "real", stream_id); /* Emulate WAVEFORMATEX struct: */ - sh->wf = malloc(sizeof(WAVEFORMATEX)); - memset(sh->wf, 0, sizeof(WAVEFORMATEX)); + sh->wf = calloc(1, sizeof(*sh->wf)); sh->wf->nChannels = 0;//sh->channels; sh->wf->wBitsPerSample = 16; sh->wf->nSamplesPerSec = 0;//sh->samplerate; @@ -1518,9 +1515,8 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer) mp_msg(MSGT_DEMUX,MSGL_V,"video fourcc: %.4s (%x)\n", (char *)&sh->format, sh->format); /* emulate BITMAPINFOHEADER */ - sh->bih = malloc(sizeof(BITMAPINFOHEADER)); - memset(sh->bih, 0, sizeof(BITMAPINFOHEADER)); - sh->bih->biSize = sizeof(BITMAPINFOHEADER); + sh->bih = calloc(1, sizeof(*sh->bih)); + sh->bih->biSize = sizeof(*sh->bih); sh->disp_w = sh->bih->biWidth = stream_read_word(demuxer->stream); sh->disp_h = sh->bih->biHeight = stream_read_word(demuxer->stream); sh->bih->biPlanes = 1; @@ -1555,10 +1551,10 @@ static demuxer_t* demux_open_real(demuxer_t* demuxer) { // read and store codec extradata unsigned int cnt = codec_data_size - (stream_tell(demuxer->stream) - codec_pos); - if (cnt > 0x7fffffff - sizeof(BITMAPINFOHEADER)) { + if (cnt > 0x7fffffff - sizeof(*sh->bih)) { mp_msg(MSGT_DEMUX, MSGL_ERR,"Extradata too big (%u)\n", cnt); } else { - sh->bih = realloc(sh->bih, sizeof(BITMAPINFOHEADER) + cnt); + sh->bih = realloc(sh->bih, sizeof(*sh->bih) + cnt); sh->bih->biSize += cnt; stream_read(demuxer->stream, ((unsigned char*)(sh->bih+1)), cnt); } |