changeset 29691:183ea012e25b

Change grow_array argument from void ** to void *, this avoids a aliasing violation (thus making gcc 4.4.x compile the code correctly) and allows to get rid of some casts at the expense of making the code less clear.
author reimar
date Wed, 30 Sep 2009 07:27:43 +0000
parents b5e23411a51e
children 235868858ee7
files libmpdemux/demux_mkv.c
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libmpdemux/demux_mkv.c	Tue Sep 29 06:44:10 2009 +0000
+++ b/libmpdemux/demux_mkv.c	Wed Sep 30 07:27:43 2009 +0000
@@ -204,11 +204,12 @@
 
 /**
  * \brief ensures there is space for at least one additional element
- * \param array array to grow
+ * \param arrayp array to grow
  * \param nelem current number of elements in array
  * \param elsize size of one array element
  */
-static void grow_array(void **array, int nelem, size_t elsize) {
+static void grow_array(void *arrayp, int nelem, size_t elsize) {
+  void **array = arrayp;
   if (!(nelem & 31))
     *array = realloc(*array, (nelem + 32) * elsize);
 }
@@ -235,7 +236,7 @@
     if (mkv_d->cluster_positions[i] == position)
       return;
 
-  grow_array((void **)&mkv_d->cluster_positions, mkv_d->num_cluster_pos,
+  grow_array(&mkv_d->cluster_positions, mkv_d->num_cluster_pos,
              sizeof(uint64_t));
   mkv_d->cluster_positions[mkv_d->num_cluster_pos++] = position;
 }
@@ -1079,7 +1080,7 @@
       if (time != EBML_UINT_INVALID && track != EBML_UINT_INVALID
           && pos != EBML_UINT_INVALID)
         {
-          grow_array((void **)&mkv_d->indexes, mkv_d->num_indexes, sizeof(mkv_index_t));
+          grow_array(&mkv_d->indexes, mkv_d->num_indexes, sizeof(mkv_index_t));
           mkv_d->indexes[mkv_d->num_indexes].tnum = track;
           mkv_d->indexes[mkv_d->num_indexes].timecode = time;
           mkv_d->indexes[mkv_d->num_indexes].filepos =mkv_d->segment_start+pos;