[FFmpeg-devel] Realmedia patch

Reimar Döffinger Reimar.Doeffinger
Wed Aug 27 16:03:16 CEST 2008


On Wed, Aug 27, 2008 at 09:09:07AM -0400, Ronald S. Bultje wrote:
> On Wed, Aug 27, 2008 at 9:04 AM, Reimar D?ffinger
> <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:
> > On Wed, Aug 27, 2008 at 07:53:14AM -0400, Ronald S. Bultje wrote:
> >> I tried the following:
> >>
> >>     int i;
> >>     char *orig_buf = buf;
> >>     const char hex_table[16] = { '0', '1', '2', '3', '4', '5', '6', '7',
> >>                                  '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' };
> >
> > Why not static?
> 
> Ah, now it gets interesting. So, I first made it static const (or
> const static), but since it's const, I figured it didn't make a
> difference except for keeping it alive between multiple function-calls
> which doesn't seem all that useful, so I removed it. Apparently I'm
> not quite getting it, so: what's the difference between const static
> and "just" const? Is one more efficient in memory-usage than the
> other?

Well, with a good compiler probably not (and even the const it might be
able to figure out itself), but just going by the code, a naive compiler
(and probably gcc -O0) would store the constant in .rodata and upon
each function call copy it onto the stack (it might also initialize
it with code, but that is already an optimization).
IOW, static means it should be in some global location, const does
not say anything about it, it might make it easier for the compiler
to decide it is stupid to make an on-stack copy though.




More information about the ffmpeg-devel mailing list