diff options
author | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-09 17:51:40 +0200 |
---|---|---|
committer | Diego 'Flameeyes' Pettenò <flameeyes@gmail.com> | 2008-05-09 17:51:40 +0200 |
commit | 902d66eb8304ccffdb683b7130e9f548011b8d30 (patch) | |
tree | 9cdd73b5f68131ba2d4944d17e183b4313bdb559 /src/demuxers | |
parent | a51427608e2f4543ae0cb0598517a1e4f6b0928b (diff) | |
download | xine-lib-902d66eb8304ccffdb683b7130e9f548011b8d30.tar.gz xine-lib-902d66eb8304ccffdb683b7130e9f548011b8d30.tar.bz2 |
Avoid loop for common memory operations (zeroing, copying, moving).
Use the proper function for common memory operations (memset() for
zeroing, memcpy() for copying, memmove() for moving), instead of
looping through arrays.
By extension, remove loops to reset arrays when they were allocated
with calloc() and thus already zeroed.
Diffstat (limited to 'src/demuxers')
-rw-r--r-- | src/demuxers/demux_mpeg_pes.c | 5 | ||||
-rw-r--r-- | src/demuxers/demux_slave.c | 6 | ||||
-rw-r--r-- | src/demuxers/demux_str.c | 4 | ||||
-rw-r--r-- | src/demuxers/demux_ts.c | 6 | ||||
-rw-r--r-- | src/demuxers/demux_wc3movie.c | 2 |
5 files changed, 5 insertions, 18 deletions
diff --git a/src/demuxers/demux_mpeg_pes.c b/src/demuxers/demux_mpeg_pes.c index 477a071a4..32dd2cb51 100644 --- a/src/demuxers/demux_mpeg_pes.c +++ b/src/demuxers/demux_mpeg_pes.c @@ -274,7 +274,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) while ((p[2] != 1) || p[0] || p[1]) { /* resync code */ - for(n=0;n<5;n++) p[n]=p[n+1]; + memmove(p, p+1, 5); i = read_data(this, p+5, (off_t) 1); if (i != 1) { this->status = DEMUX_FINISHED; @@ -306,8 +306,7 @@ static void demux_mpeg_pes_parse_pack (demux_mpeg_pes_t *this, int preview_mode) p = buf->mem; /* copy local buffer to fifo element. */ - for (n = 0; n < sizeof (buf6); n++) - p[ n ] = buf6[ n ]; + memcpy(p, buf6, sizeof(buf6)); if (preview_mode) buf->decoder_flags = BUF_FLAG_PREVIEW; diff --git a/src/demuxers/demux_slave.c b/src/demuxers/demux_slave.c index c2d427d8c..28a89a973 100644 --- a/src/demuxers/demux_slave.c +++ b/src/demuxers/demux_slave.c @@ -186,10 +186,8 @@ static int demux_slave_next (demux_slave_t *this) { buf->decoder_flags = decoder_flags; /* set decoder info */ - for( i = 0; i < BUF_NUM_DEC_INFO; i++ ) { - buf->decoder_info[i] = this->decoder_info[i]; - buf->decoder_info_ptr[i] = this->decoder_info_ptr[i]; - } + memcpy(buf->decoder_info, this->decoder_info, sizeof(this->decoder_info)); + memcpy(buf->decoder_info_ptr, this->decoder_info_ptr, sizeof(this->decoder_info)); memset(this->decoder_info, 0, sizeof(this->decoder_info)); memset(this->decoder_info_ptr, 0, sizeof(this->decoder_info_ptr)); diff --git a/src/demuxers/demux_str.c b/src/demuxers/demux_str.c index 97e025504..1e750f183 100644 --- a/src/demuxers/demux_str.c +++ b/src/demuxers/demux_str.c @@ -188,9 +188,7 @@ static int open_str_file(demux_str_t *this) { unsigned char check_bytes[STR_CHECK_BYTES]; int local_offset, sector, channel; - for (channel = 0; channel < STR_MAX_CHANNELS; channel++) { - this->channel_type[channel] = 0; - } + memset(this->channel_type, 0, sizeof(this->channel_type)); this->input->seek(this->input, 0, SEEK_SET); if (this->input->read(this->input, check_bytes, STR_CHECK_BYTES) != diff --git a/src/demuxers/demux_ts.c b/src/demuxers/demux_ts.c index c3b1c2bad..6d854e4c3 100644 --- a/src/demuxers/demux_ts.c +++ b/src/demuxers/demux_ts.c @@ -2278,12 +2278,6 @@ static demux_plugin_t *open_plugin (demux_class_t *class_gen, this->status = DEMUX_FINISHED; -#ifdef TS_READ_STATS - for (i=0; i<=NPKT_PER_READ; i++) { - this->rstat[i] = 0; - } -#endif - /* DVBSUB */ this->spu_pid = INVALID_PID; this->spu_langs_count = 0; diff --git a/src/demuxers/demux_wc3movie.c b/src/demuxers/demux_wc3movie.c index dab0d2619..64ae431fb 100644 --- a/src/demuxers/demux_wc3movie.c +++ b/src/demuxers/demux_wc3movie.c @@ -380,8 +380,6 @@ static int open_mve_file(demux_mve_t *this) { /* allocate space for the shot offset index and set offsets to 0 */ this->shot_offsets = calloc(this->number_of_shots, sizeof(off_t)); this->current_shot = 0; - for (i = 0; i < this->number_of_shots; i++) - this->shot_offsets[i] = 0; /* skip the SOND chunk */ this->input->seek(this->input, 12, SEEK_CUR); |