[FFmpeg-devel] MPEG-PS demuxer index memory usage

Bobby Bingham uhmmmm
Sat Jan 5 07:46:25 CET 2008


On Fri, 4 Jan 2008 16:46:02 -0800 (PST)
Trent Piepho <xyzzy at speakeasy.org> wrote:

> On Fri, 4 Jan 2008, [iso-8859-1] M?ns Rullg?rd wrote:
> > > -            memmove(entries + index + 1, entries + index,
> > > sizeof(AVIndexEntry)*(st->nb_index_entries - index));
> > > +            memmove(&entries[index + 1], &entries[index],
> > > sizeof(AVIndexEntry)*(st->nb_index_entries - index));
> >
> > Those two lines are exactly equivalent.  In C, the construct a[b]
> > can always be replaced by ((a) + (b)) and conversely.  This means
> > that the
> 
> You mean "*((a) +(b))" replaces "a[b]", or "&a[b]" replaces
> "((a)+(b))", of course.
> 
> > first argument to the above memmove() call could be written
> > &index[entries]+1, or even &1[entries]+index, should one feel thusly
> > inclined.
> 
> I don't think &1[entries]+index would work.  1[entries] is
> dereferencing an integer, which should be an error, but might be just
> a warning under some compiler/options/c standard combinations.  Maybe
> you meant "&entries[1]+index", which would work.

&entries[i]+index == ((entries)+(1))+index
                  == ((1)+(entries))+index
                  == &1[entries]+index

It should work either way.
-- 
Bobby Bingham
Never trust atoms.  Or anything made of atoms.
??????????????????????




More information about the ffmpeg-devel mailing list