[GRASS-dev] what can come before G_gisinit()?
Hamish
hamish_nospam at yahoo.com
Sun Oct 8 02:18:27 EDT 2006
Glynn Clements 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();
module = G_define_module();
user_input(argc,argv);
..
fprintf(stderr, "\tMAP:\t %s\n", choice->fn);
..
}
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!!
..
name = G_define_option();
sampling_method = G_define_option();
..
if (G_parser(argc,argv))
exit(EXIT_FAILURE);
..
G_strcpy(choice->fn, name->answer);
choice->wrum = sampling_method->answer[0];
..
}
patch.h:
struct CHOICE {
char fn[30], reg[30],out[30],
wrum;
int core2, size2, shape2,
edge, fb, coremap, units;
int perim2, trace, patchmap;
int Mx[4];
int att[9], size[9], shape[8],
boundary[5], perim[8], core[11];
} ;
...
/** main.c **/
void user_input();
too many choices,
Hamish
More information about the grass-dev
mailing list