[GRASS-SVN] r36482 - grass/branches/releasebranch_6_4/lib/proj
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Mar 25 08:20:12 EDT 2009
Author: pkelly
Date: 2009-03-25 08:20:12 -0400 (Wed, 25 Mar 2009)
New Revision: 36482
Modified:
grass/branches/releasebranch_6_4/lib/proj/convert.c
Log:
Don't mix memory deallocation functions between GRASS and external libraries;
causes problems on Windows. Thanks to Jef for the patch. Fixes bug 537.
Modified: grass/branches/releasebranch_6_4/lib/proj/convert.c
===================================================================
--- grass/branches/releasebranch_6_4/lib/proj/convert.c 2009-03-25 07:37:29 UTC (rev 36481)
+++ grass/branches/releasebranch_6_4/lib/proj/convert.c 2009-03-25 12:20:12 UTC (rev 36482)
@@ -54,7 +54,7 @@
int esri_style, int prettify)
{
OGRSpatialReferenceH hSRS;
- char *wkt;
+ char *wkt, *local_wkt;
hSRS = GPJ_grass_to_osr(proj_info, proj_units);
@@ -69,8 +69,10 @@
else
OSRExportToWkt(hSRS, &wkt);
+ local_wkt = G_store(wkt);
+ CPLFree(wkt);
OSRDestroySpatialReference(hSRS);
- return wkt;
+ return local_wkt;
}
/**
@@ -220,9 +222,9 @@
OSRDestroySpatialReference(hSRS);
G_free(modwkt);
CPLFree(wkt);
+ pj_dalloc(proj4);
if (proj4 != proj4mod)
- pj_dalloc(proj4);
- G_free(proj4mod);
+ G_free(proj4mod);
G_free(datum);
G_free(params);
G_free(datumlongname);
@@ -310,7 +312,11 @@
/* -------------------------------------------------------------------- */
temp_projinfo = G_create_key_value();
- pszRemaining = pszProj4;
+ /* Create "local" copy of proj4 string so we can modify and free it
+ * using GRASS functions */
+ pszRemaining = G_store(pszProj4);
+ CPLFree(pszProj4);
+ pszProj4 = pszRemaining;
while ((pszRemaining = strstr(pszRemaining, "+")) != NULL) {
char *pszToken, *pszValue;
@@ -561,7 +567,7 @@
G_free_key_value(temp_projinfo);
}
- free(pszProj4); /* hopefully the same as CPLFree()! */
+ G_free(pszProj4);
/* -------------------------------------------------------------------- */
/* Set the linear units. */
@@ -783,8 +789,8 @@
/* -------------------------------------------------------------------- */
for (i = 0; papszDatumEquiv[i] != NULL; i += 2) {
if (EQUAL(*ppszDatum, papszDatumEquiv[i])) {
- CPLFree(*ppszDatum);
- *ppszDatum = CPLStrdup(papszDatumEquiv[i + 1]);
+ G_free(*ppszDatum);
+ *ppszDatum = G_store(papszDatumEquiv[i + 1]);
break;
}
}
More information about the grass-commit
mailing list