[GRASS-dev] [GRASS GIS] #32: r.what: shouldn't use static buffers for the inputs

Glynn Clements glynn at gclements.plus.com
Sun Feb 17 20:18:37 EST 2008


Ivan Shmakov wrote:

>  > @@ -144,4 +147,16 @@
>  >    projection = G_projection();
> 
> 	BTW, did anyone notice that the `projection' variable is unused?
> 
> 	Apparently, the only side effect of this line is to have
> 	G__init_window () called (via G_get_set_window ().)  The
> 	questions are:
> 
> 	* is this call necessary in `r.what.rast'?

I doubt it.

> 	* shouldn't this side effect of G_projection () and
> 	  G_get_set_window () be documented?

Almost everything ends up calling G_get_set_window() at some point.

This is one of the most common examples of the idiom of initialising
values upon first use.

However, this particular case is a bit of a mess. There are actually
two static windows: dbwindow in (G_get_window()) and G__.window. In
practice, both G_get_window() and G__init_window() invariably end up
setting both to the same value.

[Actually, G_get_window() doesn't set either if GRASS_REGION is set;
but as it's unlikely to change over the lifetime of the process, it
doesn't make any noticable difference.]

-- 
Glynn Clements <glynn at gclements.plus.com>


More information about the grass-dev mailing list