summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-07 20:27:54 +0200
committerDiego 'Flameeyes' Pettenò <flameeyes@gmail.com>2008-05-07 20:27:54 +0200
commited72565137c93ab0385a10036d234f5f4dd1b960 (patch)
tree68089f28d7fd5e79e39ee81b5a2d0bd4876908f9
parent1230c21aea047e429f050c5ceeff20820e0d6044 (diff)
downloadxine-lib-ed72565137c93ab0385a10036d234f5f4dd1b960.tar.gz
xine-lib-ed72565137c93ab0385a10036d234f5f4dd1b960.tar.bz2
Avoid memset() on newly allocated memory areas.
If needed, use calloc() to allocate the area so that it's already reset by the time it returns.
-rw-r--r--src/audio_out/audio_oss_out.c4
-rw-r--r--src/demuxers/asfheader.c9
-rw-r--r--src/demuxers/demux_avi.c1
-rw-r--r--src/demuxers/demux_ogg.c2
-rw-r--r--src/demuxers/demux_qt.c1
5 files changed, 4 insertions, 13 deletions
diff --git a/src/audio_out/audio_oss_out.c b/src/audio_out/audio_oss_out.c
index 22dc4284c..df29a43ea 100644
--- a/src/audio_out/audio_oss_out.c
+++ b/src/audio_out/audio_oss_out.c
@@ -883,9 +883,7 @@ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *da
"audio_oss_out: ...probing output buffer size: "));
this->buffer_size = 0;
- if( (buf=malloc(1024)) != NULL ) {
- memset(buf,0,1024);
-
+ if( (buf=calloc(1, 1024)) != NULL ) {
do {
c = write(audio_fd,buf,1024);
if( c != -1 )
diff --git a/src/demuxers/asfheader.c b/src/demuxers/asfheader.c
index f95c68e41..5db25d07f 100644
--- a/src/demuxers/asfheader.c
+++ b/src/demuxers/asfheader.c
@@ -581,10 +581,9 @@ static int asf_header_parse_content_description(asf_header_t *header_pub, uint8_
if (buffer_len < 10)
return 0;
- content = malloc(sizeof(asf_content_t));
+ content = calloc(1, sizeof(asf_content_t));
if (!content)
return 0;
- memset(content, 0, sizeof(asf_content_t));
asf_reader_init(&reader, buffer, buffer_len);
asf_reader_get_16(&reader, &title_length);
@@ -617,10 +616,9 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
uint32_t object_count;
uint16_t junk;
- asf_header = malloc(sizeof(asf_header_internal_t));
+ asf_header = calloc(1, sizeof(asf_header_internal_t));
if (!asf_header)
return NULL;
- memset(asf_header, 0, sizeof(asf_header_internal_t));
lprintf("parsing_asf_header\n");
if (buffer_len < 6) {
@@ -703,10 +701,9 @@ asf_header_t *asf_header_new (uint8_t *buffer, int buffer_len) {
}
if (!asf_header->pub.content) {
lprintf("no content object present\n");
- asf_header->pub.content = malloc(sizeof(asf_content_t));
+ asf_header->pub.content = calloc(1, sizeof(asf_content_t));
if (!asf_header->pub.content)
goto exit_error;
- memset(asf_header->pub.content, 0, sizeof(asf_content_t));
}
return &asf_header->pub;
diff --git a/src/demuxers/demux_avi.c b/src/demuxers/demux_avi.c
index 01efe0e53..6a942c4df 100644
--- a/src/demuxers/demux_avi.c
+++ b/src/demuxers/demux_avi.c
@@ -882,7 +882,6 @@ static avi_t *AVI_init(demux_avi_t *this) {
this->AVI_errno = AVI_ERR_NO_MEM;
return 0;
}
- memset((void *)a,0,sizeof(avi_audio_t));
AVI->audio[AVI->n_audio] = a;
a->audio_strn = num_stream;
diff --git a/src/demuxers/demux_ogg.c b/src/demuxers/demux_ogg.c
index c8c39c991..e0cddfcf4 100644
--- a/src/demuxers/demux_ogg.c
+++ b/src/demuxers/demux_ogg.c
@@ -2027,7 +2027,6 @@ static demux_plugin_t *anx_open_plugin (demux_class_t *class_gen,
*/
this = calloc(1, sizeof(demux_ogg_t));
- memset (this, 0, sizeof(demux_ogg_t));
this->stream = stream;
this->input = input;
@@ -2073,7 +2072,6 @@ static demux_plugin_t *ogg_open_plugin (demux_class_t *class_gen,
*/
this = calloc(1, sizeof(demux_ogg_t));
- memset (this, 0, sizeof(demux_ogg_t));
this->stream = stream;
this->input = input;
diff --git a/src/demuxers/demux_qt.c b/src/demuxers/demux_qt.c
index 525160dd2..e51344798 100644
--- a/src/demuxers/demux_qt.c
+++ b/src/demuxers/demux_qt.c
@@ -1736,7 +1736,6 @@ static qt_error build_frame_table(qt_trak *trak,
media_id_counts = calloc(trak->stsd_atoms_count, sizeof(int));
if (!media_id_counts)
return QT_NO_MEMORY;
- memset(media_id_counts, 0, trak->stsd_atoms_count * sizeof(int));
/* iterate through each start chunk in the stsc table */
for (i = 0; i < trak->sample_to_chunk_count; i++) {