diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-12-18 21:56:02 +0100 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2007-12-18 21:56:02 +0100 |
commit | 5413ef667ff604985850f95e39b4266852356d85 (patch) | |
tree | 86769efa051020b9d1981b4536c4d34e8a89b391 | |
parent | cf22e0aa95b17a8ea15f9d3cc3fb6b458aac8ed3 (diff) | |
download | xine-lib-5413ef667ff604985850f95e39b4266852356d85.tar.gz xine-lib-5413ef667ff604985850f95e39b4266852356d85.tar.bz2 |
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
-rw-r--r-- | src/input/libreal/real.c | 2 | ||||
-rw-r--r-- | src/input/libreal/rmff.c | 21 |
2 files changed, 10 insertions, 13 deletions
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; i<header->fileheader->num_headers; i++) { - header->streams[i]=NULL; - } + header->streams = calloc(header->fileheader->num_headers, sizeof(rmff_mdpr_t*)); for (i=1; i<header->fileheader->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; |