summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-04-14 18:30:19 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2007-04-14 18:30:19 +0200
commite0565eaa178fc0ad4eabcbc48c50085f95bb56a8 (patch)
tree2538a0670c63086213af10fcc8f56532ce7a5792 /src
parentdc36f8d045cf4f723c44766f44c92e1810e37f4f (diff)
downloadxine-lib-e0565eaa178fc0ad4eabcbc48c50085f95bb56a8.tar.gz
xine-lib-e0565eaa178fc0ad4eabcbc48c50085f95bb56a8.tar.bz2
Use xine_xcalloc instead of xine_xmalloc when mutiplying the number of elements by the size of the single element.
Diffstat (limited to 'src')
-rw-r--r--src/demuxers/demux_film.c2
-rw-r--r--src/demuxers/demux_flac.c4
-rw-r--r--src/demuxers/demux_flv.c2
-rw-r--r--src/demuxers/demux_mpgaudio.c2
-rw-r--r--src/demuxers/demux_qt.c3
-rw-r--r--src/demuxers/demux_real.c4
-rw-r--r--src/demuxers/demux_tta.c2
-rw-r--r--src/demuxers/demux_wc3movie.c8
-rw-r--r--src/input/input_cdda.c2
-rw-r--r--src/input/input_dvd.c2
-rw-r--r--src/input/input_file.c6
-rw-r--r--src/input/input_smb.c4
-rw-r--r--src/input/libreal/real.c2
-rw-r--r--src/libxinevdec/bitplane.c8
-rw-r--r--src/post/mosaico/mosaico.c2
-rw-r--r--src/video_out/video_out_fb.c26
-rw-r--r--src/video_out/video_out_xshm.c2
-rw-r--r--src/xine-engine/load_plugins.c4
-rw-r--r--src/xine-engine/scratch.c7
19 files changed, 37 insertions, 55 deletions
diff --git a/src/demuxers/demux_film.c b/src/demuxers/demux_film.c
index d3cedc0e1..69c3eea60 100644
--- a/src/demuxers/demux_film.c
+++ b/src/demuxers/demux_film.c
@@ -258,7 +258,7 @@ static int open_film_file(demux_film_t *film) {
film->frequency = BE_32(&film_header[i + 8]);
film->sample_count = BE_32(&film_header[i + 12]);
film->sample_table =
- xine_xmalloc(film->sample_count * sizeof(film_sample_t));
+ xine_xcalloc(film->sample_count, sizeof(film_sample_t));
for (j = 0; j < film->sample_count; j++) {
film->sample_table[j].sample_offset =
diff --git a/src/demuxers/demux_flac.c b/src/demuxers/demux_flac.c
index f52da4d03..116409d1f 100644
--- a/src/demuxers/demux_flac.c
+++ b/src/demuxers/demux_flac.c
@@ -179,8 +179,8 @@ static int open_flac_file(demux_flac_t *flac) {
case 3:
lprintf ("SEEKTABLE metadata, %d bytes\n", block_length);
flac->seekpoint_count = block_length / FLAC_SEEKPOINT_SIZE;
- flac->seekpoints = xine_xmalloc(flac->seekpoint_count *
- sizeof(flac_seekpoint_t));
+ flac->seekpoints = xine_xcalloc(flac->seekpoint_count,
+ sizeof(flac_seekpoint_t));
for (i = 0; i < flac->seekpoint_count; i++) {
if (flac->input->read(flac->input, buffer, FLAC_SEEKPOINT_SIZE) != FLAC_SEEKPOINT_SIZE)
return 0;
diff --git a/src/demuxers/demux_flv.c b/src/demuxers/demux_flv.c
index 0588b408e..5de878b4d 100644
--- a/src/demuxers/demux_flv.c
+++ b/src/demuxers/demux_flv.c
@@ -278,7 +278,7 @@ static int parse_flv_var(demux_flv_t *this,
if (key && keylen == 5 && !strncmp(key, "times", 5)) {
if (this->index)
free (this->index);
- this->index = xine_xmalloc(num*sizeof(flv_index_entry_t));
+ this->index = xine_xcalloc(num, sizeof(flv_index_entry_t));
this->num_indices = num;
for (num = 0; num < this->num_indices && tmp < end; num++) {
if (*tmp++ == FLV_DATA_TYPE_NUMBER) {
diff --git a/src/demuxers/demux_mpgaudio.c b/src/demuxers/demux_mpgaudio.c
index 31b2d33ff..bd55c9f0a 100644
--- a/src/demuxers/demux_mpgaudio.c
+++ b/src/demuxers/demux_mpgaudio.c
@@ -413,7 +413,7 @@ static vbri_header_t* parse_vbri_header(mpg_audio_frame_t *frame,
lprintf("entry_frames: %d\n", vbri->entry_frames);
if ((ptr + (vbri->toc_entries + 1) * vbri->entry_size) >= (buf + bufsize)) return 0;
- vbri->toc = xine_xmalloc (sizeof(int) * (vbri->toc_entries + 1));
+ vbri->toc = xine_xcalloc ((vbri->toc_entries + 1), sizeof(int));
if (!vbri->toc) {
free (vbri);
return NULL;
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c
index f837a2272..aa2ad8955 100644
--- a/src/demuxers/demux_qt.c
+++ b/src/demuxers/demux_qt.c
@@ -929,12 +929,11 @@ static qt_error parse_trak_atom (qt_trak *trak,
/* allocate space for each of the properties unions */
trak->stsd_atoms_count = BE_32(&trak_atom[i + 8]);
- trak->stsd_atoms = xine_xmalloc(trak->stsd_atoms_count * sizeof(properties_t));
+ trak->stsd_atoms = xine_xcalloc(trak->stsd_atoms_count, sizeof(properties_t));
if (!trak->stsd_atoms) {
last_error = QT_NO_MEMORY;
goto free_trak;
}
- memset(trak->stsd_atoms, 0, trak->stsd_atoms_count * sizeof(properties_t));
atom_pos = i + 0x10;
properties_offset = 0x0C;
diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c
index 11b0dbf38..f0488bc47 100644
--- a/src/demuxers/demux_real.c
+++ b/src/demuxers/demux_real.c
@@ -692,7 +692,7 @@ unknown:
this->video_stream->mdpr->avg_bit_rate);
/* Allocate fragment offset table */
- this->fragment_tab = xine_xmalloc(FRAGMENT_TAB_SIZE*sizeof(uint32_t));
+ this->fragment_tab = xine_xcalloc(FRAGMENT_TAB_SIZE, sizeof(uint32_t));
this->fragment_tab_max = FRAGMENT_TAB_SIZE;
}
@@ -1282,7 +1282,7 @@ static int demux_real_send_chunk(demux_plugin_t *this_gen) {
frames = (stream_read_word(this) & 0xf0) >> 4;
/* 2 bytes per frame size */
- sizes = xine_xmalloc(frames*sizeof(int));
+ sizes = xine_xcalloc(frames, sizeof(int));
for(i = 0; i < frames; i++)
sizes[i] = stream_read_word(this);
diff --git a/src/demuxers/demux_tta.c b/src/demuxers/demux_tta.c
index 81b9c6ede..724404a5b 100644
--- a/src/demuxers/demux_tta.c
+++ b/src/demuxers/demux_tta.c
@@ -87,7 +87,7 @@ static int open_tta_file(demux_tta_t *this) {
return 0;
}
- this->seektable = xine_xmalloc(sizeof(uint32_t)*this->totalframes);
+ this->seektable = xine_xcalloc(this->totalframes, sizeof(uint32_t));
this->input->read(this->input, this->seektable, sizeof(uint32_t)*this->totalframes);
/* Skip the CRC32 */
diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c
index fa1cfb17d..8645c9189 100644
--- a/src/demuxers/demux_wc3movie.c
+++ b/src/demuxers/demux_wc3movie.c
@@ -380,17 +380,15 @@ static int open_mve_file(demux_mve_t *this) {
this->number_of_shots = LE_32(&preamble[0]);
/* allocate space for the shot offset index and set offsets to 0 */
- this->shot_offsets = xine_xmalloc(this->number_of_shots * sizeof(off_t));
+ this->shot_offsets = xine_xcalloc(this->number_of_shots, sizeof(off_t));
this->current_shot = 0;
- for (i = 0; i < this->number_of_shots; i++)
- this->shot_offsets[i] = 0;
/* skip the SOND chunk */
this->input->seek(this->input, 12, SEEK_CUR);
/* load the palette chunks */
- this->palettes = xine_xmalloc(this->number_of_shots * PALETTE_SIZE *
- sizeof(palette_entry_t));
+ this->palettes = xine_xcalloc(this->number_of_shots, PALETTE_SIZE *
+ sizeof(palette_entry_t));
for (i = 0; i < this->number_of_shots; i++) {
/* make sure there was a valid palette chunk preamble */
if (this->input->read(this->input, preamble, PREAMBLE_SIZE) !=
diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c
index 8bb35effd..fe4c7f932 100644
--- a/src/input/input_cdda.c
+++ b/src/input/input_cdda.c
@@ -2450,7 +2450,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) {
if(this->cddb.num_tracks) {
int t;
- this->cddb.track = (trackinfo_t *) xine_xmalloc(sizeof(trackinfo_t) * this->cddb.num_tracks);
+ this->cddb.track = (trackinfo_t *) xine_xcalloc(this->cddb.num_tracks, sizeof(trackinfo_t));
for(t = 0; t < this->cddb.num_tracks; t++) {
int length = (toc->toc_entries[t].first_frame_minute * CD_SECONDS_PER_MINUTE +
diff --git a/src/input/input_dvd.c b/src/input/input_dvd.c
index ac09e934b..1a8861289 100644
--- a/src/input/input_dvd.c
+++ b/src/input/input_dvd.c
@@ -1629,7 +1629,7 @@ static input_plugin_t *dvd_class_get_instance (input_class_t *class_gen, xine_st
this->mem_stack = 0;
this->mem_stack_max = 1024;
- this->mem = xine_xmalloc(sizeof(unsigned char *) * this->mem_stack_max);
+ this->mem = xine_xcalloc(this->mem_stack_max, sizeof(unsigned char *));
if (!this->mem) {
free(this);
return NULL;
diff --git a/src/input/input_file.c b/src/input/input_file.c
index fd2b0e733..0ec25e1f8 100644
--- a/src/input/input_file.c
+++ b/src/input/input_file.c
@@ -723,9 +723,9 @@ static xine_mrl_t **file_class_get_dir (input_class_t *this_gen,
return NULL;
}
- dir_files = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t) * MAXFILES);
- hide_files = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t) * MAXFILES);
- norm_files = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t) * MAXFILES);
+ dir_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
+ hide_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
+ norm_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
while((pdirent = readdir(pdir)) != NULL) {
diff --git a/src/input/input_smb.c b/src/input/input_smb.c
index 1b1f15565..4cacebf89 100644
--- a/src/input/input_smb.c
+++ b/src/input/input_smb.c
@@ -258,8 +258,8 @@ static xine_mrl_t **smb_class_get_dir (input_class_t *this_gen,
}
if ((dir = smbc_opendir(current_path_smb)) >= 0){
- xine_mrl_t *dir_files = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t) * MAXFILES);
- xine_mrl_t *norm_files = (xine_mrl_t *) xine_xmalloc(sizeof(xine_mrl_t) * MAXFILES);
+ xine_mrl_t *dir_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
+ xine_mrl_t *norm_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t));
int num_dir_files=0;
int num_norm_files=0;
while ((pdirent = smbc_readdir(dir)) != NULL){
diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c
index dc0c001bd..da7c0c443 100644
--- a/src/input/libreal/real.c
+++ b/src/input/libreal/real.c
@@ -461,7 +461,7 @@ rmff_header_t *real_parse_sdp(char *data, char **stream_rules, uint32_t bandwidt
desc->copyright,
desc->abstract);
header->data=rmff_new_dataheader(0,0);
- header->streams = xine_xmalloc(sizeof(rmff_mdpr_t*)*(desc->stream_count+1));
+ header->streams = xine_xcalloc((desc->stream_count+1), sizeof(rmff_mdpr_t*));
lprintf("number of streams: %u\n", desc->stream_count);
for (i=0; i<desc->stream_count; i++) {
diff --git a/src/libxinevdec/bitplane.c b/src/libxinevdec/bitplane.c
index 373d5d8b1..62f7a19db 100644
--- a/src/libxinevdec/bitplane.c
+++ b/src/libxinevdec/bitplane.c
@@ -1160,8 +1160,8 @@ static void bitplane_decode_data (video_decoder_t *this_gen,
this->bytes_per_pixel = 1;
/* New Buffer for indexes (palette based formats) */
- this->index_buf = xine_xmalloc( this->num_pixel * this->bytes_per_pixel );
- this->index_buf_hist = xine_xmalloc( this->num_pixel * this->bytes_per_pixel );
+ this->index_buf = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
+ this->index_buf_hist = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
this->num_bitplanes = bih->biPlanes;
this->camg_mode = bih->biCompression;
@@ -1316,8 +1316,8 @@ static void bitplane_decode_data (video_decoder_t *this_gen,
}
}
if( this->index_buf == NULL ) {
- this->index_buf = xine_xmalloc( (this->num_pixel * this->bytes_per_pixel) );
- this->index_buf_hist = xine_xmalloc( (this->num_pixel * this->bytes_per_pixel) );
+ this->index_buf = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
+ this->index_buf_hist = xine_xcalloc( this->num_pixel, this->bytes_per_pixel );
for (i = 0; i < (this->num_pixel * this->bytes_per_pixel); i++) {
this->index_buf[i] = 0;
this->index_buf_hist[i] = 0;
diff --git a/src/post/mosaico/mosaico.c b/src/post/mosaico/mosaico.c
index 40173bd5d..cc7fefe2c 100644
--- a/src/post/mosaico/mosaico.c
+++ b/src/post/mosaico/mosaico.c
@@ -160,7 +160,7 @@ static post_plugin_t *mosaico_open_plugin(post_class_t *class_gen, int inputs,
_x_post_init(&this->post, 0, inputs);
- this->pip = (mosaico_pip_t *)xine_xmalloc(sizeof(mosaico_pip_t) * (inputs - 1));
+ this->pip = (mosaico_pip_t *)xine_xcalloc((inputs - 1), sizeof(mosaico_pip_t));
this->pip_count = inputs - 1;
pthread_cond_init(&this->vpts_limit_changed, NULL);
diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c
index e88def112..f480fb7d0 100644
--- a/src/video_out/video_out_fb.c
+++ b/src/video_out/video_out_fb.c
@@ -356,21 +356,10 @@ static void reset_dest_pointers(fb_frame_t *frame, int flags)
static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame,
uint32_t width, uint32_t height, int format)
{
- if(frame->chunk[0])
- {
- free(frame->chunk[0]);
- frame->chunk[0] = NULL;
- }
- if(frame->chunk[1])
- {
- free(frame->chunk[1]);
- frame->chunk[1] = NULL;
- }
- if(frame->chunk[2])
- {
- free(frame->chunk[2]);
- frame->chunk[2] = NULL;
- }
+ free(frame->chunk[0]);
+ free(frame->chunk[1]);
+ free(frame->chunk[2]);
+ memset(frame->chunk, 0, sizeof(frame->chunk[0])*3);
if(this->use_zero_copy)
{
@@ -380,10 +369,9 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame,
}
else
{
- if(frame->data)
- free(frame->data);
- frame->data = xine_xmalloc(frame->sc.output_width *
- frame->sc.output_height *
+ free(frame->data);
+ frame->data = xine_xcalloc(frame->sc.output_width *
+ frame->sc.output_height,
this->bytes_per_pixel);
}
diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c
index 00d3bee1c..82270ec8a 100644
--- a/src/video_out/video_out_xshm.c
+++ b/src/video_out/video_out_xshm.c
@@ -284,7 +284,7 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo,
this->bytes_per_pixel = this->bpp / 8;
this->image_byte_order = myimage->byte_order;
- myimage->data = xine_xmalloc (width * this->bytes_per_pixel * height);
+ myimage->data = xine_xcalloc (width * height, this->bytes_per_pixel);
}
return myimage;
diff --git a/src/xine-engine/load_plugins.c b/src/xine-engine/load_plugins.c
index 2f07591cf..ca1f87c7a 100644
--- a/src/xine-engine/load_plugins.c
+++ b/src/xine-engine/load_plugins.c
@@ -952,7 +952,7 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
file = xine_xmalloc(sizeof(plugin_file_t));
node->file = file;
file->filename = strdup(line+1);
- node->info = xine_xmalloc(2*sizeof(plugin_info_t));
+ node->info = xine_xcalloc(2, sizeof(plugin_info_t));
node->info[1].type = PLUGIN_NONE;
decoder_info = NULL;
vo_info = NULL;
@@ -1036,7 +1036,7 @@ static void load_plugin_list(FILE *fp, xine_sarray_t *plugins) {
for( s = value, i = 0; s && sscanf(s," %lu",&lu) > 0; i++ ) {
s = strchr(s+1, ' ');
}
- decoder_info->supported_types = xine_xmalloc((i+1)*sizeof(uint32_t));
+ decoder_info->supported_types = xine_xcalloc((i+1), sizeof(uint32_t));
for( s = value, i = 0; s && sscanf(s," %lu",&lu) > 0; i++ ) {
decoder_info->supported_types[i] = lu;
s = strchr(s+1, ' ');
diff --git a/src/xine-engine/scratch.c b/src/xine-engine/scratch.c
index 67281b041..4b694699f 100644
--- a/src/xine-engine/scratch.c
+++ b/src/xine-engine/scratch.c
@@ -112,11 +112,8 @@ scratch_buffer_t *_x_new_scratch_buffer (int num_lines) {
this = xine_xmalloc (sizeof (scratch_buffer_t));
- this->lines = xine_xmalloc (sizeof (char *) * (num_lines + 1));
- this->ordered = xine_xmalloc (sizeof (char *) * (num_lines + 1));
-
- for (i = 0; i <= num_lines; i++)
- this->lines[i] = this->ordered[i] = NULL;
+ this->lines = xine_xcalloc ((num_lines + 1), sizeof(char*));
+ this->ordered = xine_xcalloc ((num_lines + 1), sizeof(char*));
this->scratch_printf = scratch_printf;
this->get_content = scratch_get_content;