[GRASS5] Projection programs
Eric G. Miller
egm2 at jps.net
Mon Feb 3 23:50:36 EST 2003
On Mon, Feb 03, 2003 at 10:05:05PM +0000, Paul Kelly wrote:
> I would be grateful if somebody familiar with malloc and free etc. could
> have a quick look at the changes I made to v.mkquads and i.points3 (the
> two files mentioned above) just to check my implementation.
If you're asking about convert.c in v.mkquads, your usage is erroneous.
G_find_key_value() returns a pointer to the value in the key_value
struct array or *NULL*. First, you don't need to allocate any memory;
second, you're clobbering it; Third, if ellps is not found and a NULL
pointer is returned you try to copy "wgs84" like sprintf (NULL, "wgs84);
Oops!
I think what you want is something like:
const char *ellps_default = "wgs84";
char *ellps;
....
ellps = G_find_key_value ("ellps", in_proj_keys);
if (ellps == NULL)
ellps = ellps_default;
G_set_key_value ("ellps", ellps, out_proj_keys);
....
The G_set_key_value function makes copies of the strings (if needed) for
the key_value array.
I haven't looked at i.points3.
--
echo ">gra.fcw at 2ztr< eryyvZ .T pveR" | rot13 | reverse
More information about the grass-dev
mailing list