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 <[EMAIL PROTECTED]>
_______________________________________________
grass-dev mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/grass-dev

Reply via email to