[GRASS-dev] adding units and vertical datum metadata to raster
maps
Glynn Clements
glynn at gclements.plus.com
Thu May 10 06:43:39 EDT 2007
Hamish wrote:
> I have hacked together the attached code to add units and vertical datum
> metadata to raster maps. It still needs some cleanup before going into
> CVS, but right now I am interested in comments on the approach taken.
> [it works]
>
> TODO: buffer overflow checking
>
>
> TODO: create a fn in r.info to take care of G_asprint() work, right now
> the "fancy output" section of the module is an ugly mess.
> [non-functional code, due to me being lost WRT passing pointers]
>
> /*
> if (G_asprintf(&line, "Location: %s", G_location()) > 0)
> printline(line);
> else
> G_fatal_error(_("Cannot allocate memory for string"));
> */
> compose_line( &line, "Location: %s", G_location() );
> printline(line);
> ....
>
> void compose_line(char *line, const char *fmt, ...)
> {
> va_list ap;
>
> line = NULL;
> va_start(ap, fmt);
>
> if( G_asprintf(line, fmt, ap) <= 0 )
This won't work; we need a G_vasprintf() function which takes a
va_list.
Move the body of G_asprintf() into G_vasprintf(), and implement
G_asprintf() as:
int G_asprintf(char **out, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = G_vasprintf(out, fmt, va);
va_end(ap);
return ret;
}
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list