diff -r dcabf02a88e6 -r 86afb17d1492 src/demuxers/demux_nsf.c --- a/src/demuxers/demux_nsf.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/demuxers/demux_nsf.c Sun Apr 20 18:03:04 2008 +0100 @@ -106,9 +106,9 @@ static int open_nsf_file(demux_nsf_t *th 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); diff -r dcabf02a88e6 -r 86afb17d1492 src/demuxers/demux_real.c --- a/src/demuxers/demux_real.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/demuxers/demux_real.c Sun Apr 20 18:03:04 2008 +0100 @@ -284,17 +284,17 @@ static mdpr_t *real_parse_mdpr(const cha 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); @@ -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 = 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_p frames = (stream_read_word(this) & 0xf0) >> 4; /* 2 bytes per frame size */ - sizes = xine_xmalloc(frames*sizeof(int)); + sizes = calloc(frames, sizeof(int)); for(i = 0; i < frames; i++) sizes[i] = stream_read_word(this); diff -r dcabf02a88e6 -r 86afb17d1492 src/input/input_cdda.c --- a/src/input/input_cdda.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/input/input_cdda.c Sun Apr 20 18:03:04 2008 +0100 @@ -418,10 +418,9 @@ static int read_cdrom_toc(int fd, cdrom_ 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->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->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_plu /* 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_s 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; } @@ -2458,7 +2453,7 @@ static int cdda_plugin_open (input_plugi 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 *) 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 -r dcabf02a88e6 -r 86afb17d1492 src/input/input_dvd.c --- a/src/input/input_dvd.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/input/input_dvd.c Sun Apr 20 18:03:04 2008 +0100 @@ -1632,7 +1632,7 @@ static input_plugin_t *dvd_class_get_ins this->mem_stack = 0; this->mem_stack_max = 1024; - this->mem = xine_xmalloc(sizeof(unsigned char *) * this->mem_stack_max); + this->mem = calloc(this->mem_stack_max, sizeof(unsigned char *)); if (!this->mem) { free(this); return NULL; diff -r dcabf02a88e6 -r 86afb17d1492 src/input/input_file.c --- a/src/input/input_file.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/input/input_file.c Sun Apr 20 18:03:04 2008 +0100 @@ -689,9 +689,9 @@ static xine_mrl_t **file_class_get_dir ( 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 *) 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 -r dcabf02a88e6 -r 86afb17d1492 src/input/input_smb.c --- a/src/input/input_smb.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/input/input_smb.c Sun Apr 20 18:03:04 2008 +0100 @@ -256,8 +256,8 @@ static xine_mrl_t **smb_class_get_dir (i } 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 *) 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 -r dcabf02a88e6 -r 86afb17d1492 src/input/libreal/real.c --- a/src/input/libreal/real.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/input/libreal/real.c Sun Apr 20 18:03:04 2008 +0100 @@ -458,7 +458,7 @@ rmff_header_t *real_parse_sdp(char *data 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 = calloc((desc->stream_count+1), sizeof(rmff_mdpr_t*)); lprintf("number of streams: %u\n", desc->stream_count); for (i=0; istream_count; i++) { @@ -660,7 +660,7 @@ rmff_header_t *real_setup_and_get_heade 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 -r dcabf02a88e6 -r 86afb17d1492 src/input/libreal/rmff.c --- a/src/input/libreal/rmff.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/input/libreal/rmff.c Sun Apr 20 18:03:04 2008 +0100 @@ -351,17 +351,17 @@ static rmff_mdpr_t *rmff_scan_mdpr(const 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 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 ch 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; diff -r dcabf02a88e6 -r 86afb17d1492 src/libxinevdec/bitplane.c --- a/src/libxinevdec/bitplane.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/libxinevdec/bitplane.c Sun Apr 20 18:03:04 2008 +0100 @@ -1158,8 +1158,8 @@ static void bitplane_decode_data (video_ 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 = 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_ } } 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 = 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 -r dcabf02a88e6 -r 86afb17d1492 src/post/mosaico/mosaico.c --- a/src/post/mosaico/mosaico.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/post/mosaico/mosaico.c Sun Apr 20 18:03:04 2008 +0100 @@ -158,7 +158,7 @@ static post_plugin_t *mosaico_open_plugi _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 *)calloc((inputs - 1), sizeof(mosaico_pip_t)); this->pip_count = inputs - 1; pthread_cond_init(&this->vpts_limit_changed, NULL); diff -r dcabf02a88e6 -r 86afb17d1492 src/video_out/video_out_fb.c --- a/src/video_out/video_out_fb.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/video_out/video_out_fb.c Sun Apr 20 18:03:04 2008 +0100 @@ -324,21 +324,10 @@ static void frame_reallocate(fb_driver_t 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 } else { - if(frame->data) - free(frame->data); - frame->data = xine_xmalloc(frame->sc.output_width * - frame->sc.output_height * + free(frame->data); + frame->data = calloc(frame->sc.output_width * + frame->sc.output_height, this->bytes_per_pixel); } diff -r dcabf02a88e6 -r 86afb17d1492 src/video_out/video_out_xshm.c --- a/src/video_out/video_out_xshm.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/video_out/video_out_xshm.c Sun Apr 20 18:03:04 2008 +0100 @@ -276,7 +276,7 @@ static XImage *create_ximage (xshm_drive 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 = calloc (width * height, this->bytes_per_pixel); } return myimage; diff -r dcabf02a88e6 -r 86afb17d1492 src/xine-engine/load_plugins.c --- a/src/xine-engine/load_plugins.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/xine-engine/load_plugins.c Sun Apr 20 18:03:04 2008 +0100 @@ -945,7 +945,7 @@ static void load_plugin_list(FILE *fp, x 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 = 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, x 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 = 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 -r dcabf02a88e6 -r 86afb17d1492 src/xine-engine/scratch.c --- a/src/xine-engine/scratch.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/xine-engine/scratch.c Sun Apr 20 18:03:04 2008 +0100 @@ -109,11 +109,8 @@ scratch_buffer_t *_x_new_scratch_buffer 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 = 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; diff -r dcabf02a88e6 -r 86afb17d1492 src/xine-utils/array.c --- a/src/xine-utils/array.c Tue Apr 15 01:05:22 2008 +0100 +++ b/src/xine-utils/array.c Sun Apr 20 18:03:04 2008 +0100 @@ -56,7 +56,7 @@ xine_array_t *xine_array_new(size_t init 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;