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@gclements.plus.com>
martinl
2
Hi,
you are right, thanks for pointing it out...
Fixed in svn-trunk
http://trac.osgeo.org/grass/changeset/29672
Martin
2008/1/11, Glynn Clements <glynn@gclements.plus.com>:
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@gclements.plus.com>
_______________________________________________
grass-dev mailing list
grass-dev@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-dev
--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *