[GRASS5] Re: r.sunmask - memory leakage in GRASS lib
Eric G. Miller
egm2 at jps.net
Tue Jun 12 01:32:26 EDT 2001
Here's a diff that fixes all the significant leakages in libgis (from
r.sunmask's point of view). I'm sure there are quite a few still in
there.
Index: file_name.c
===================================================================
RCS file: /grassrepository/grass/src/libes/gis/file_name.c,v
retrieving revision 1.3
diff -r1.3 file_name.c
30a31
> char *location = G__location_path();
40c41
< sprintf(path,"%s/%s", G__location_path(), xmapset);
---
> sprintf(path,"%s/%s", location, xmapset);
41a43,44
> else if (mapset && *mapset)
> sprintf(path,"%s/%s", location, mapset);
43,46c46
< if (mapset && *mapset)
< sprintf(path,"%s/%s", G__location_path(), mapset);
< else
< sprintf(path,"%s/%s", G__location_path(), G_mapset());
---
> sprintf(path,"%s/%s", location, G_mapset());
47a48,49
> G_free (location);
>
Index: get_row.c
===================================================================
RCS file: /grassrepository/grass/src/libes/gis/get_row.c,v
retrieving revision 1.8
diff -r1.8 get_row.c
1025c1025
< static char *name=NULL, *mapset=NULL;
---
> static char *name=NULL, *mapset=NULL, *dummy;
1042c1042
< if (G_find_file(dir_name, NULL_FILE, mapset)==NULL)
---
> if ((dummy = G_find_file(dir_name, NULL_FILE, mapset))==NULL)
1050c1050,1051
<
---
> G_free (dummy);
>
Index: open.c
===================================================================
RCS file: /grassrepository/grass/src/libes/gis/open.c,v
retrieving revision 1.1.1.1
diff -r1.1.1.1 open.c
92c92
< char xname[512], xmapset[512];
---
> char xname[512], xmapset[512], *dummy;
109c109
< if (! G_find_file (element, name, mapset))
---
> if ((dummy = G_find_file (element, name, mapset)) == NULL)
110a111
> G_free (dummy);
--
Eric G. Miller <egm2 at jps.net>
More information about the grass-dev
mailing list