From cbc85406d8e3c86c48f5b162881fa10c95e675ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Wed, 13 Jun 2007 16:45:32 +0200 Subject: Use strndup rather than just strdup to avoid overflows. (transplanted from 47f7f33b32805da6e8f58513c38e01dc6a595fb8) --HG-- extra : transplant_source : G%F7%F3%3B2%80%5D%A6%E8%F5%85%13%C3%8E%01%DCjY_%B8 --- src/demuxers/demux_nsf.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_nsf.c b/src/demuxers/demux_nsf.c index 81f42044f..d81010846 100644 --- a/src/demuxers/demux_nsf.c +++ b/src/demuxers/demux_nsf.c @@ -106,9 +106,9 @@ static int open_nsf_file(demux_nsf_t *this) { this->total_songs = header[6]; this->current_song = header[7]; - this->title = strdup(&header[0x0E]); - this->artist = strdup(&header[0x2E]); - this->copyright = strdup(&header[0x4E]); + this->title = strndup((char*)&header[0x0E], 0x20); + this->artist = strndup((char*)&header[0x2E], 0x20); + this->copyright = strndup((char*)&header[0x4E], 0x20); this->filesize = this->input->get_length(this->input); -- cgit v1.2.3 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 From 8de6eaea0323456e20bc2547074306e8d610ff3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 18 Dec 2007 20:57:33 +0100 Subject: Use calloc() when the allocated size would be counted by multiplying the size of an item for the number of items. (transplanted from efc9d92af3d7927cbf5534b5612fd98af541ff95) --HG-- extra : transplant_source : %EF%C9%D9%2A%F3%D7%92%7C%BFU4%B5a/%D9%8A%F5A%FF%95 --- src/input/input_cdda.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) (limited to 'src') diff --git a/src/input/input_cdda.c b/src/input/input_cdda.c index 5746bdb99..445b1f217 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -418,10 +418,9 @@ static int read_cdrom_toc(int fd, cdrom_toc *toc) { toc->total_tracks = toc->last_track - toc->first_track + 1; /* allocate space for the toc entries */ - toc->toc_entries = - (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry)); + toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry)); if (!toc->toc_entries) { - perror("malloc"); + perror("calloc"); return -1; } @@ -529,10 +528,9 @@ static int read_cdrom_toc(int fd, cdrom_toc *toc) { toc->total_tracks = toc->last_track - toc->first_track + 1; /* allocate space for the toc entries */ - toc->toc_entries = - (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry)); + toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry)); if (!toc->toc_entries) { - perror("malloc"); + perror("calloc"); return -1; } @@ -642,10 +640,9 @@ static int read_cdrom_toc(int fd, cdrom_toc *toc) { toc->total_tracks = toc->last_track - toc->first_track + 1; /* allocate space for the toc entries */ - toc->toc_entries = - (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry)); + toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry)); if (!toc->toc_entries) { - perror("malloc"); + perror("calloc"); return -1; } @@ -835,10 +832,9 @@ static int read_cdrom_toc(cdda_input_plugin_t *this_gen, cdrom_toc *toc) { /* allocate space for the toc entries */ - toc->toc_entries = - (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry)); + toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry)); if (!toc->toc_entries) { - perror("malloc"); + perror("calloc"); return -1; } @@ -1081,10 +1077,9 @@ static int network_read_cdrom_toc(xine_stream_t *stream, int fd, cdrom_toc *toc) toc->total_tracks = toc->last_track - toc->first_track + 1; /* allocate space for the toc entries */ - toc->toc_entries = - (cdrom_toc_entry *)malloc(toc->total_tracks * sizeof(cdrom_toc_entry)); + toc->toc_entries = calloc(toc->total_tracks, sizeof(cdrom_toc_entry)); if (!toc->toc_entries) { - perror("malloc"); + perror("calloc"); return -1; } -- cgit v1.2.3 From cf22e0aa95b17a8ea15f9d3cc3fb6b458aac8ed3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 18 Dec 2007 21:36:15 +0100 Subject: Use calloc() when allocating an array of elements. (transplanted from 3640d3cbe551f96df932b7d6218b071b910a237b) --HG-- extra : transplant_source : 6%40%D3%CB%E5Q%F9m%F92%B7%D6%21%8B%07%1B%91%0A%23%7B --- src/demuxers/demux_real.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 761c55bf8..6e6ce6f4f 100644 --- a/src/demuxers/demux_real.c +++ b/src/demuxers/demux_real.c @@ -284,17 +284,17 @@ static mdpr_t *real_parse_mdpr(const char *data) { mdpr->duration=_X_BE_32(&data[28]); mdpr->stream_name_size=data[32]; - mdpr->stream_name=malloc(sizeof(char)*(mdpr->stream_name_size+1)); + mdpr->stream_name=calloc(mdpr->stream_name_size+1, sizeof(char)); memcpy(mdpr->stream_name, &data[33], mdpr->stream_name_size); mdpr->stream_name[(int)mdpr->stream_name_size]=0; mdpr->mime_type_size=data[33+mdpr->stream_name_size]; - mdpr->mime_type=malloc(sizeof(char)*(mdpr->mime_type_size+1)); + mdpr->mime_type=calloc(mdpr->mime_type_size+1, sizeof(char)); memcpy(mdpr->mime_type, &data[34+mdpr->stream_name_size], mdpr->mime_type_size); mdpr->mime_type[(int)mdpr->mime_type_size]=0; mdpr->type_specific_len=_X_BE_32(&data[34+mdpr->stream_name_size+mdpr->mime_type_size]); - mdpr->type_specific_data=malloc(sizeof(char)*(mdpr->type_specific_len)); + mdpr->type_specific_data=calloc(mdpr->type_specific_len, sizeof(char)); memcpy(mdpr->type_specific_data, &data[38+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len); -- cgit v1.2.3 From 5413ef667ff604985850f95e39b4266852356d85 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 18 Dec 2007 21:56:02 +0100 Subject: Use calloc() when allocating an array of elements. (transplanted from e9e85d6bcc7e9aafb1dc019f3505de2dafe940bf) --HG-- extra : transplant_source : %E9%E8%5Dk%CC%7E%9A%AF%B1%DC%01%9F5%05%DE-%AF%E9%40%BF --- src/input/libreal/real.c | 2 +- src/input/libreal/rmff.c | 21 +++++++++------------ 2 files changed, 10 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/input/libreal/real.c b/src/input/libreal/real.c index 9ea65d9df..925b0fdf8 100644 --- a/src/input/libreal/real.c +++ b/src/input/libreal/real.c @@ -660,7 +660,7 @@ rmff_header_t *real_setup_and_get_header(rtsp_t *rtsp_session, uint32_t bandwid lprintf("Stream description size: %i\n", size); - description = malloc(sizeof(char)*(size+1)); + description = calloc(size+1, sizeof(char)); if( rtsp_read_data(rtsp_session, description, size) <= 0) { xine_buffer_free(buf); diff --git a/src/input/libreal/rmff.c b/src/input/libreal/rmff.c index b79eb5e0f..05f914782 100644 --- a/src/input/libreal/rmff.c +++ b/src/input/libreal/rmff.c @@ -351,17 +351,17 @@ static rmff_mdpr_t *rmff_scan_mdpr(const char *data) { mdpr->duration=_X_BE_32(&data[36]); mdpr->stream_name_size=data[40]; - mdpr->stream_name = malloc(sizeof(char)*(mdpr->stream_name_size+1)); + mdpr->stream_name = calloc(mdpr->stream_name_size+1, sizeof(char)); memcpy(mdpr->stream_name, &data[41], mdpr->stream_name_size); mdpr->stream_name[mdpr->stream_name_size]=0; mdpr->mime_type_size=data[41+mdpr->stream_name_size]; - mdpr->mime_type = malloc(sizeof(char)*(mdpr->mime_type_size+1)); + mdpr->mime_type = calloc(mdpr->mime_type_size+1, sizeof(char)); memcpy(mdpr->mime_type, &data[42+mdpr->stream_name_size], mdpr->mime_type_size); mdpr->mime_type[mdpr->mime_type_size]=0; mdpr->type_specific_len=_X_BE_32(&data[42+mdpr->stream_name_size+mdpr->mime_type_size]); - mdpr->type_specific_data = malloc(sizeof(char)*(mdpr->type_specific_len)); + mdpr->type_specific_data = calloc(mdpr->type_specific_len, sizeof(char)); memcpy(mdpr->type_specific_data, &data[46+mdpr->stream_name_size+mdpr->mime_type_size], mdpr->type_specific_len); @@ -381,22 +381,22 @@ static rmff_cont_t *rmff_scan_cont(const char *data) { lprintf("warning: unknown object version in CONT: 0x%04x\n", cont->object_version); } cont->title_len=_X_BE_16(&data[10]); - cont->title = malloc(sizeof(char)*(cont->title_len+1)); + cont->title = calloc((cont->title_len+1), sizeof(char)); memcpy(cont->title, &data[12], cont->title_len); cont->title[cont->title_len]=0; pos=cont->title_len+12; cont->author_len=_X_BE_16(&data[pos]); - cont->author = malloc(sizeof(char)*(cont->author_len+1)); + cont->author = calloc(cont->author_len+1, sizeof(char)); memcpy(cont->author, &data[pos+2], cont->author_len); cont->author[cont->author_len]=0; pos=pos+2+cont->author_len; cont->copyright_len=_X_BE_16(&data[pos]); - cont->copyright = malloc(sizeof(char)*(cont->copyright_len+1)); + cont->copyright = calloc(cont->copyright_len+1, sizeof(char)); memcpy(cont->copyright, &data[pos+2], cont->copyright_len); cont->copyright[cont->copyright_len]=0; pos=pos+2+cont->copyright_len; cont->comment_len=_X_BE_16(&data[pos]); - cont->comment = malloc(sizeof(char)*(cont->comment_len+1)); + cont->comment = calloc(cont->comment_len+1, sizeof(char)); memcpy(cont->comment, &data[pos+2], cont->comment_len); cont->comment[cont->comment_len]=0; @@ -444,10 +444,7 @@ rmff_header_t *rmff_scan_header(const char *data) { header->fileheader=rmff_scan_fileheader(ptr); ptr += header->fileheader->size; - header->streams = malloc(sizeof(rmff_mdpr_t*)*(header->fileheader->num_headers)); - for (i=0; ifileheader->num_headers; i++) { - header->streams[i]=NULL; - } + header->streams = calloc(header->fileheader->num_headers, sizeof(rmff_mdpr_t*)); for (i=1; ifileheader->num_headers; i++) { chunk_type = _X_BE_32(ptr); @@ -627,7 +624,7 @@ rmff_mdpr_t *rmff_new_mdpr( mdpr->mime_type_size=strlen(mime_type); } mdpr->type_specific_len=type_specific_len; - mdpr->type_specific_data = malloc(sizeof(char)*type_specific_len); + mdpr->type_specific_data = calloc(type_specific_len, sizeof(char)); memcpy(mdpr->type_specific_data,type_specific_data,type_specific_len); mdpr->mlti_data=NULL; -- cgit v1.2.3 From dd702a3abc16986a2bbc3d3429fce1f621f94c0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Tue, 18 Dec 2007 22:45:28 +0100 Subject: Use calloc() when allocating an array of elements. (transplanted from 332f543689ebef22ef38e052c437d6998ac8fe66) --HG-- extra : transplant_source : 3/T6%89%EB%EF%22%EF8%E0R%C47%D6%99%8A%C8%FEf --- src/xine-utils/array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/xine-utils/array.c b/src/xine-utils/array.c index 6c226c7ef..f6989fbb6 100644 --- a/src/xine-utils/array.c +++ b/src/xine-utils/array.c @@ -56,7 +56,7 @@ xine_array_t *xine_array_new(size_t initial_size) { if (initial_size < MIN_CHUNK_SIZE) initial_size = MIN_CHUNK_SIZE; - new_array->chunk = (void**)malloc(sizeof(void*) * initial_size); + new_array->chunk = (void**)calloc(initial_size, sizeof(void*)); if (!new_array->chunk) { free(new_array); return NULL; -- cgit v1.2.3 From 95973431372272b749762591cd4b82fe7e587a84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20=27Flameeyes=27=20Petten=C3=B2?= Date: Sat, 19 Apr 2008 01:54:11 +0200 Subject: Replace xine_xcalloc usage with calloc, for the revisions transplanted from 1.2 series. --- 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 | 2 +- src/video_out/video_out_xshm.c | 2 +- src/xine-engine/load_plugins.c | 4 ++-- src/xine-engine/scratch.c | 4 ++-- 12 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/demuxers/demux_real.c b/src/demuxers/demux_real.c index 6e6ce6f4f..5a20ac92b 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_xcalloc(FRAGMENT_TAB_SIZE, sizeof(uint32_t)); + this->fragment_tab = calloc(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_xcalloc(frames, sizeof(int)); + sizes = calloc(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 445b1f217..f43f79fc3 100644 --- a/src/input/input_cdda.c +++ b/src/input/input_cdda.c @@ -2453,7 +2453,7 @@ static int cdda_plugin_open (input_plugin_t *this_gen ) { if(this->cddb.num_tracks) { int t; - this->cddb.track = (trackinfo_t *) xine_xcalloc(this->cddb.num_tracks, sizeof(trackinfo_t)); + this->cddb.track = (trackinfo_t *) calloc(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 67af70b05..620ce98c4 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_xcalloc(this->mem_stack_max, sizeof(unsigned char *)); + this->mem = calloc(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 aa16e5bce..62d0d73d5 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_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)); + dir_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); + hide_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); + norm_files = (xine_mrl_t *) calloc(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 cdabf410c..777b80b46 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_xcalloc(MAXFILES, sizeof(xine_mrl_t)); - xine_mrl_t *norm_files = (xine_mrl_t *) xine_xcalloc(MAXFILES, sizeof(xine_mrl_t)); + xine_mrl_t *dir_files = (xine_mrl_t *) calloc(MAXFILES, sizeof(xine_mrl_t)); + xine_mrl_t *norm_files = (xine_mrl_t *) calloc(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 925b0fdf8..472120895 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_xcalloc((desc->stream_count+1), sizeof(rmff_mdpr_t*)); + header->streams = calloc((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 b6940813f..a3bdba74b 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_xcalloc( this->num_pixel, this->bytes_per_pixel ); - this->index_buf_hist = xine_xcalloc( this->num_pixel, this->bytes_per_pixel ); + this->index_buf = calloc( this->num_pixel, this->bytes_per_pixel ); + this->index_buf_hist = calloc( 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_xcalloc( this->num_pixel, this->bytes_per_pixel ); - this->index_buf_hist = xine_xcalloc( this->num_pixel, this->bytes_per_pixel ); + this->index_buf = calloc( this->num_pixel, this->bytes_per_pixel ); + this->index_buf_hist = calloc( 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 05c1f5f19..40f0ffb4c 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_xcalloc((inputs - 1), sizeof(mosaico_pip_t)); + this->pip = (mosaico_pip_t *)calloc((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 de5aa5d8d..6a331c910 100644 --- a/src/video_out/video_out_fb.c +++ b/src/video_out/video_out_fb.c @@ -338,7 +338,7 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame, else { free(frame->data); - frame->data = xine_xcalloc(frame->sc.output_width * + frame->data = calloc(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 e9898d6d0..ec97aa5c1 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_xcalloc (width * height, this->bytes_per_pixel); + myimage->data = calloc (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 b0557a4c7..b8471e907 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_xcalloc(2, sizeof(plugin_info_t)); + node->info = calloc(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_xcalloc((i+1), sizeof(uint32_t)); + decoder_info->supported_types = calloc((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 e4c1dd3e1..c73ab3525 100644 --- a/src/xine-engine/scratch.c +++ b/src/xine-engine/scratch.c @@ -109,8 +109,8 @@ scratch_buffer_t *_x_new_scratch_buffer (int num_lines) { this = xine_xmalloc (sizeof (scratch_buffer_t)); - this->lines = xine_xcalloc ((num_lines + 1), sizeof(char*)); - this->ordered = xine_xcalloc ((num_lines + 1), sizeof(char*)); + this->lines = calloc ((num_lines + 1), sizeof(char*)); + this->ordered = calloc ((num_lines + 1), sizeof(char*)); this->scratch_printf = scratch_printf; this->get_content = scratch_get_content; -- cgit v1.2.3