[antlr-interest] Error in generated C code (struct referenced without being initialized)
Jim Idle
jimi at temporal-wave.com
Tue Feb 3 12:19:39 PST 2009
Gavin Lambert wrote:
> At 07:46 4/02/2009, Jim Idle wrote:
> >I can no longer remember why it does not do this. I will look
> >in to it, but I think that the issue is you can return anything
> >you like in the structure and so if it is not something that
> >can be initialized to NULL, it breaks the code generation.
>
> You could memset(foo, 0, sizeof(*foo)) it... :) (Arguably this should
> be done for scopes as well, especially if you're reusing previously
> populated structures.)
>
The overhead of memset is too much. That is why I changed from callocing
it to having the user initialize the data. Valgrind makes it painfully
obvious that these sorts of things really drag down the performance and
it is better to explicitly initialize and free just those things that
need to be. I also think that for maintainability it is better to
program with explicit intent.
Jim
More information about the antlr-interest
mailing list