[postgis-commits] svn - r3828 - trunk/liblwgeom

postgis-commits at postgis.refractions.net postgis-commits at postgis.refractions.net
Tue Mar 10 09:18:52 PDT 2009


Author: mcayland
Date: 2009-03-10 09:18:52 -0700 (Tue, 10 Mar 2009)
New Revision: 3828

Modified:
   trunk/liblwgeom/lwgunparse.c
Log:
Remove some GCC-isms from the unparser related to setting array sizes at run-time rather than compile time. Per report from Mateusz Loskot.


Modified: trunk/liblwgeom/lwgunparse.c
===================================================================
--- trunk/liblwgeom/lwgunparse.c	2009-03-10 15:54:19 UTC (rev 3827)
+++ trunk/liblwgeom/lwgunparse.c	2009-03-10 16:18:52 UTC (rev 3828)
@@ -306,9 +306,12 @@
 {
         uchar *temp;
         int dimcount;
-        double first_point[dims];
-        double last_point[dims];
+	double *first_point;
+	double *last_point;
 
+        first_point = lwalloc(dims * sizeof(double));
+        last_point = lwalloc(dims * sizeof(double));
+
 	int cnt = read_int(&geom);
 	int orig_cnt = cnt;
 	if ( cnt == 0 ){
@@ -350,14 +353,24 @@
              (first_point[0] != last_point[0] || first_point[1] != last_point[1] ) &&
 			 (current_unparser_check_flags & PARSER_CHECK_CLOSURE))
 			{
+			lwfree(first_point);
+			lwfree(last_point);
                 	LWGEOM_WKT_UNPARSER_ERROR(UNPARSER_ERROR_UNCLOSED);	
 			}
 
 
 		/* Ensure that POLYGON has a minimum of 4 points */
         	if ((current_unparser_check_flags & PARSER_CHECK_MINPOINTS) && orig_cnt < 4)
+		{
+			lwfree(first_point);
+			lwfree(last_point);
                 	LWGEOM_WKT_UNPARSER_ERROR(UNPARSER_ERROR_MOREPOINTS);
+		}
 	}
+
+	lwfree(first_point);
+	lwfree(last_point);
+
 	return geom;
 }
 
@@ -807,9 +820,12 @@
 {
 	uchar *temp;
 	int dimcount;
-	double first_point[dims];
-	double last_point[dims];
+	double *first_point;
+	double *last_point;
 
+        first_point = lwalloc(dims * sizeof(double));
+        last_point = lwalloc(dims * sizeof(double));
+
 	int cnt = read_int(&geom);
 	int orig_cnt = cnt;
 
@@ -844,18 +860,22 @@
 		(first_point[1] != last_point[1])) &&
 		(current_unparser_check_flags & PARSER_CHECK_CLOSURE)) 
 	{
+		lwfree(first_point);
+		lwfree(last_point);
 		LWGEOM_WKB_UNPARSER_ERROR(UNPARSER_ERROR_UNCLOSED);
 	}
 
-/*	if (memcmp(&first_point, &last_point, sizeof(double) * dims) &&
-		(current_unparser_check_flags & PARSER_CHECK_CLOSURE)) {
-		LWGEOM_WKB_UNPARSER_ERROR(UNPARSER_ERROR_UNCLOSED);
-	}
-*/
 	/* Ensure that POLYGON has a minimum of 4 points */
 	if ((current_unparser_check_flags & PARSER_CHECK_MINPOINTS) && orig_cnt < 4)
+	{
+		lwfree(first_point);
+		lwfree(last_point);
 		LWGEOM_WKB_UNPARSER_ERROR(UNPARSER_ERROR_MOREPOINTS);
+	}
 
+	lwfree(first_point);
+	lwfree(last_point);
+
 	return geom;
 }
 



More information about the postgis-commits mailing list