[GRASS-dev] G_gettext initialization
Hamish
hamish_nospam at yahoo.com
Thu Nov 16 18:35:29 EST 2006
> Brad wrote:
> > In G_gettext (lib/gis/locale.c), I ran across this code:
> >
> > char *
> > G_gettext(const char *package, const char *msgid)
> > {
> > #if defined(HAVE_LIBINTL_H) && defined(USE_NLS)
> > static char now_bound[4096];
> > static int initialized;
> >
> > if (!initialized)
> > {
> > ...
> > initialized = 1;
> > }
> > ...
> > }
> >
> > Is there any particular reason that 'initialized' is not actually
> > initialized? Is there a reason for this?
Glynn:
> I don't understand what you are asking; can you elaborate?
>
> The above is a common idiom used to perform "one-shot" initialisation
> the first time that a function is called.
I think what Brad is getting at is that the "initialized" variable is
being used uninitialized in the if().
- static int initialized;
+ static int initialized = 0;
there is humor in that.
Hamish
More information about the grass-dev
mailing list