changeset 32111:7c8d240d37a6

Replace sizeof(type)
author reimar
date Sun, 12 Sep 2010 13:26:39 +0000
parents f9a0197ad67c
children 741bcef4ad3a
files libmpdemux/aviprint.c libmpdemux/demux_audio.c libmpdemux/demux_lavf.c libmpdemux/demux_mkv.c libmpdemux/demux_rawaudio.c libmpdemux/demux_realaud.c libmpdemux/demux_vqf.c
diffstat 7 files changed, 19 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/aviprint.c	Sun Sep 12 13:14:18 2010 +0000
+++ b/libmpdemux/aviprint.c	Sun Sep 12 13:26:39 2010 +0000
@@ -117,12 +117,12 @@
 	mp_msg(MSGT_HEADER, verbose_level, "  biBitCount %d\n", h->biBitCount);
 	mp_msg(MSGT_HEADER, verbose_level, "  biCompression %d='%.4s'\n", h->biCompression, (char *)&h->biCompression);
 	mp_msg(MSGT_HEADER, verbose_level, "  biSizeImage %d\n", h->biSizeImage);
-  if (h->biSize > sizeof(BITMAPINFOHEADER))
+  if (h->biSize > sizeof(*h))
   {
     int i;
     uint8_t* p = (uint8_t*)(h + 1);
     mp_msg(MSGT_HEADER, verbose_level, "Unknown extra header dump: ");
-    for (i = 0; i < h->biSize-sizeof(BITMAPINFOHEADER); i++)
+    for (i = 0; i < h->biSize-sizeof(*h); i++)
 	mp_msg(MSGT_HEADER, verbose_level, "[%x] ", *(p+i));
     mp_msg(MSGT_HEADER, verbose_level, "\n");
   }
--- a/libmpdemux/demux_audio.c	Sun Sep 12 13:14:18 2010 +0000
+++ b/libmpdemux/demux_audio.c	Sun Sep 12 13:26:39 2010 +0000
@@ -336,7 +336,7 @@
     sh_audio->audio.dwSampleSize= 0;
     sh_audio->audio.dwScale = mp3_found->mpa_spf;
     sh_audio->audio.dwRate = mp3_found->mp3_freq;
-    sh_audio->wf = malloc(sizeof(WAVEFORMATEX));
+    sh_audio->wf = malloc(sizeof(*sh_audio->wf));
     sh_audio->wf->wFormatTag = sh_audio->format;
     sh_audio->wf->nChannels = mp3_found->mp3_chans;
     sh_audio->wf->nSamplesPerSec = mp3_found->mp3_freq;
@@ -397,7 +397,7 @@
       mp_msg(MSGT_DEMUX,MSGL_ERR,"[demux_audio] Bad wav header length: too long (%d)!!!\n",l);
       l = 16;
     }
-    sh_audio->wf = w = malloc(l > sizeof(WAVEFORMATEX) ? l : sizeof(WAVEFORMATEX));
+    sh_audio->wf = w = malloc(l > sizeof(*w) ? l : sizeof(*w));
     w->wFormatTag = sh_audio->format = stream_read_word_le(s);
     w->nChannels = sh_audio->channels = stream_read_word_le(s);
     w->nSamplesPerSec = sh_audio->samplerate = stream_read_dword_le(s);
@@ -416,7 +416,7 @@
                l,w->cbSize);
         w->cbSize = l;
       }
-      stream_read(s,(char*)((char*)(w)+sizeof(WAVEFORMATEX)),w->cbSize);
+      stream_read(s,(char*)(w + 1),w->cbSize);
       l -= w->cbSize;
       if (w->wFormatTag & 0xfffe && w->cbSize >= 22)
           sh_audio->format = ((WAVEFORMATEXTENSIBLE *)w)->SubFormat;
--- a/libmpdemux/demux_lavf.c	Sun Sep 12 13:14:18 2010 +0000
+++ b/libmpdemux/demux_lavf.c	Sun Sep 12 13:26:39 2010 +0000
@@ -276,7 +276,7 @@
                 break;
             stream_type = "audio";
             priv->astreams[priv->audio_streams] = i;
-            wf= calloc(sizeof(WAVEFORMATEX) + codec->extradata_size, 1);
+            wf= calloc(sizeof(*wf) + codec->extradata_size, 1);
             // mp4a tag is used for all mp4 files no matter what they actually contain
             if(codec->codec_tag == MKTAG('m', 'p', '4', 'a'))
                 codec->codec_tag= 0;
@@ -348,7 +348,7 @@
             if(!sh_video) break;
             stream_type = "video";
             priv->vstreams[priv->video_streams] = i;
-            bih=calloc(sizeof(BITMAPINFOHEADER) + codec->extradata_size,1);
+            bih=calloc(sizeof(*bih) + codec->extradata_size,1);
 
             if(codec->codec_id == CODEC_ID_RAWVIDEO) {
                 switch (codec->pix_fmt) {
@@ -358,7 +358,7 @@
             }
             if(!codec->codec_tag)
                 codec->codec_tag= av_codec_get_tag(mp_bmp_taglists, codec->codec_id);
-            bih->biSize= sizeof(BITMAPINFOHEADER) + codec->extradata_size;
+            bih->biSize= sizeof(*bih) + codec->extradata_size;
             bih->biWidth= codec->width;
             bih->biHeight= codec->height;
             bih->biBitCount= codec->bits_per_coded_sample;
--- a/libmpdemux/demux_mkv.c	Sun Sep 12 13:14:18 2010 +0000
+++ b/libmpdemux/demux_mkv.c	Sun Sep 12 13:26:39 2010 +0000
@@ -1469,7 +1469,7 @@
         BITMAPINFOHEADER *src;
 
         if (track->private_data == NULL
-            || track->private_size < sizeof(BITMAPINFOHEADER))
+            || track->private_size < sizeof(*bih))
             return 1;
 
         src = (BITMAPINFOHEADER *) track->private_data;
@@ -1485,17 +1485,17 @@
         bih->biYPelsPerMeter = le2me_32(src->biYPelsPerMeter);
         bih->biClrUsed = le2me_32(src->biClrUsed);
         bih->biClrImportant = le2me_32(src->biClrImportant);
-        memcpy((char *) bih + sizeof(BITMAPINFOHEADER),
-               (char *) src + sizeof(BITMAPINFOHEADER),
-               track->private_size - sizeof(BITMAPINFOHEADER));
+        memcpy(bih + 1,
+               src + 1,
+               track->private_size - sizeof(*bih));
 
         if (track->v_width == 0)
             track->v_width = bih->biWidth;
         if (track->v_height == 0)
             track->v_height = bih->biHeight;
     } else {
-        bih = calloc(1, sizeof(BITMAPINFOHEADER));
-        bih->biSize = sizeof(BITMAPINFOHEADER);
+        bih = calloc(1, sizeof(*bih));
+        bih->biSize = sizeof(*bih);
         bih->biWidth = track->v_width;
         bih->biHeight = track->v_height;
         bih->biBitCount = 24;
@@ -1513,7 +1513,7 @@
             src = (uint8_t *) track->private_data + RVPROPERTIES_SIZE;
 
             cnt = track->private_size - RVPROPERTIES_SIZE;
-            bih = realloc(bih, sizeof(BITMAPINFOHEADER) + 8 + cnt);
+            bih = realloc(bih, sizeof(*bih) + 8 + cnt);
             bih->biSize = 48 + cnt;
             bih->biPlanes = 1;
             type2 = AV_RB32(src - 4);
@@ -1617,7 +1617,7 @@
 
     sh_a->default_track = track->default_track;
     sh_a->ds = demuxer->audio;
-    sh_a->wf = malloc(sizeof(WAVEFORMATEX));
+    sh_a->wf = malloc(sizeof(*sh_a->wf));
     if (track->ms_compat && (track->private_size >= sizeof(WAVEFORMATEX))) {
         WAVEFORMATEX *wf = (WAVEFORMATEX *) track->private_data;
         sh_a->wf = realloc(sh_a->wf, track->private_size);
--- a/libmpdemux/demux_rawaudio.c	Sun Sep 12 13:14:18 2010 +0000
+++ b/libmpdemux/demux_rawaudio.c	Sun Sep 12 13:26:39 2010 +0000
@@ -51,7 +51,7 @@
   WAVEFORMATEX* w;
 
   sh_audio = new_sh_audio(demuxer,0, NULL);
-  sh_audio->wf = w = malloc(sizeof(WAVEFORMATEX));
+  sh_audio->wf = w = malloc(sizeof(*w));
   w->wFormatTag = sh_audio->format = format;
   w->nChannels = sh_audio->channels = channels;
   w->nSamplesPerSec = sh_audio->samplerate = samplerate;
--- a/libmpdemux/demux_realaud.c	Sun Sep 12 13:14:18 2010 +0000
+++ b/libmpdemux/demux_realaud.c	Sun Sep 12 13:26:39 2010 +0000
@@ -287,7 +287,7 @@
 	}
 
 	/* Fill WAVEFORMATEX */
-	sh->wf = calloc(1, sizeof(WAVEFORMATEX));
+	sh->wf = calloc(1, sizeof(*sh->wf));
 	sh->wf->nChannels = sh->channels;
 	sh->wf->wBitsPerSample = sh->samplesize;
 	sh->wf->nSamplesPerSec = sh->samplerate;
--- a/libmpdemux/demux_vqf.c	Sun Sep 12 13:14:18 2010 +0000
+++ b/libmpdemux/demux_vqf.c	Sun Sep 12 13:26:39 2010 +0000
@@ -49,7 +49,7 @@
   s = demuxer->stream;
 
   sh_audio = new_sh_audio(demuxer,0, NULL);
-  sh_audio->wf = w = calloc(1, sizeof(WAVEFORMATEX)+sizeof(headerInfo));
+  sh_audio->wf = w = calloc(1, sizeof(*sh_audio->wf)+sizeof(headerInfo));
   hi = (headerInfo *)&w[1];
   w->wFormatTag = 0x1;
   sh_audio->format = mmioFOURCC('T','W','I','N'); /* TWinVQ */