Index: libmpdemux/demux_mkv.c =================================================================== --- libmpdemux/demux_mkv.c (revision 29731) +++ libmpdemux/demux_mkv.c (working copy) @@ -203,16 +203,25 @@ extern int dvdsub_id; /** - * \brief ensures there is space for at least one additional element + * \brief ensures there is space for at least one additional uint64_t * \param array 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_uint64(uint64_t **array, int nelem) { if (!(nelem & 31)) - *array = realloc(*array, (nelem + 32) * elsize); + *array = realloc(*array, (nelem + 32) * sizeof(uint64_t)); } +/** + * \brief ensures there is space for at least one additional mkv_index_t + * \param array array to grow + * \param nelem current number of elements in array + */ +static void grow_array_mkv_index(mkv_index_t **array, int nelem) { + if (!(nelem & 31)) + *array = realloc(*array, (nelem + 32) * sizeof(mkv_index_t)); +} + static mkv_track_t * demux_mkv_find_track_by_num (mkv_demuxer_t *d, int n, int type) { @@ -235,8 +244,7 @@ if (mkv_d->cluster_positions[i] == position) return; - grow_array((void **)&mkv_d->cluster_positions, mkv_d->num_cluster_pos, - sizeof(uint64_t)); + grow_array_uint64(&mkv_d->cluster_positions, mkv_d->num_cluster_pos); mkv_d->cluster_positions[mkv_d->num_cluster_pos++] = position; } @@ -1079,7 +1087,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_index(&mkv_d->indexes, mkv_d->num_indexes); 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;