From cb2dc09164a533fc544c59469f6f8bd7d1cc5e04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 14 Apr 2007 18:30:19 +0200 Subject: Use xine_xcalloc instead of xine_xmalloc when mutiplying the number of elements by the size of the single element. (transplanted from 512894f517c423fed0cadeca0d46c6d909403106) --HG-- extra : transplant_source : Q%28%94%F5%17%C4%23%FE%D0%CA%DE%CA%0DF%C6%D9%09%401%06 --- src/demuxers/demux_real.c | 4 ++-- src/input/input_cdda.c | 2 +- src/input/input_dvd.c | 2 +- src/input/input_file.c | 6 +++--- src/input/input_smb.c | 4 ++-- src/input/libreal/real.c | 2 +- src/libxinevdec/bitplane.c | 8 ++++---- src/post/mosaico/mosaico.c | 2 +- src/video_out/video_out_fb.c | 26 +++++++------------------- src/video_out/video_out_xshm.c | 2 +- src/xine-engine/load_plugins.c | 4 ++-- src/xine-engine/scratch.c | 7 ++----- 12 files changed, 27 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index fa4e87e07..761c55bf8 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -769,7 +769,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; } @@ -1386,7 +1386,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/input/input_cdda.c b/src/input/input_cdda.c index fd4dd1fa9..5746bdb99 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -2458,7 +2458,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 a891b9877..67af70b05 100644 --- a/src/input/input_dvd.c +++ b/src/input/input_dvd.c @@ -1632,7 +1632,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 f81103dcd..aa16e5bce 100644 --- a/src/input/input_file.c +++ b/src/input/input_file.c @@ -689,9 +689,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 7da9c1454..cdabf410c 100644 --- a/src/input/input_smb.c +++ b/src/input/input_smb.c @@ -256,8 +256,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 df50f0440..9ea65d9df 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -458,7 +458,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; istream_count; i++) { diff --git a/src/libxinevdec/bitplane.c b/src/libxinevdec/bitplane.c index bf868ad2a..b6940813f 100644 --- a/src/libxinevdec/bitplane.c +++ b/src/libxinevdec/bitplane.c @@ -1158,8 +1158,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; @@ -1314,8 +1314,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 50b1cfcdf..05c1f5f19 100644 --- a/src/post/mosaico/mosaico.c +++ b/src/post/mosaico/mosaico.c @@ -158,7 +158,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 95060a4d8..de5aa5d8d 100644 --- a/src/video_out/video_out_fb.c +++ b/src/video_out/video_out_fb.c @@ -324,21 +324,10 @@ static void setup_colorspace_converter(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) { @@ -348,10 +337,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 9e901821a..e9898d6d0 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.c @@ -276,7 +276,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 30077a38e..b0557a4c7 100644 --- a/src/xine-engine/load_plugins.c +++ b/src/xine-engine/load_plugins.c @@ -945,7 +945,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; @@ -1029,7 +1029,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 38b606b84..e4c1dd3e1 100644 --- a/src/xine-engine/scratch.c +++ b/src/xine-engine/scratch.c @@ -109,11 +109,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; -- cgit v1.2.3