[GRASS-dev] what can come before G_gisinit()?

Glynn Clements glynn at gclements.plus.com
Tue Oct 17 08:05:10 EDT 2006


Hamish wrote:

> > > is it ok to call G_calloc() before G_gisinit()?
> > 
> > No.
> > 
> > G_calloc() calls G_fatal_error() if calloc() fails. G_fatal_error()
> > calls G_program_name(), which uses the program name set by
> > G_gisinit().
> 
> 
> 
> Ok, r.le needs some more fixing then, e.g. r.le.patch
> 
> main.c:
> struct CHOICE *choice;
> 
> int main(){
>   struct GModule *module;
> 
>   /* allocate space for the choice data structure */
>   choice = (struct CHOICE *)G_calloc(1, sizeof(struct CHOICE));
>  ..
>   G_gisinit();

I've moved the G_gisinit() to the beginning of main, before the
G_calloc() call ...

> input.c:
> extern struct CHOICE *choice;  // again!!
> 
> void user_input (int argc, char **argv) {
>   ..
>    struct Option *name;
>    struct Option *sampling_method;
>   ..
>    G_gisinit(argv[0]);   // again!!

... and removed the extraneous G_gisinit() from user_input().

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




More information about the grass-dev mailing list