[GRASS-dev] G_gettext initialization
Brad Douglas
rez at touchofmadness.com
Thu Nov 16 21:34:46 EST 2006
On Fri, 2006-11-17 at 12:35 +1300, Hamish wrote:
> > 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;
>
Correct.
> there is humor in that.
:-)
--
Brad Douglas <rez touchofmadness com> KB8UYR/6
Address: 37.493,-121.924 / WGS84 National Map Corps #TNMC-3785
More information about the grass-dev
mailing list