[GRASS-dev] Re: Fwd: [GRASS-SVN] r29640 - grass/trunk/lib/gis
Glynn Clements
glynn at gclements.plus.com
Fri Jan 11 16:44:26 EST 2008
Markus Neteler wrote:
> it appears that Martin has solved it. Still have to test.
> Modified:
> grass/trunk/lib/gis/get_ellipse.c
> Log:
> Fixing memory leak in G_get_ellipsoid_parameters(), ticket #14
FWIW, I would consider moving the body of G_get_ellipsoid_parameters()
into a separate function, leaving something like:
G_get_ellipsoid_parameters (double *a, double *e2)
{
...
proj_keys = G_read_key_value_file(ipath, &in_stat);
stat = get_ellipsoid_parameters(proj_keys, a, e2);
G_free_key_value(proj_keys);
return stat;
}
This eliminates the need to remember to free proj_keys at each return.
Similar logic applies to handling files, i.e. using:
fp = fopen(...);
stat = process_the_file(fp, ...);
fclose(fp);
return stat;
rather than having to remember to call fclose(fp) at many different
"return" statements.
--
Glynn Clements <glynn at gclements.plus.com>
More information about the grass-dev
mailing list