[postgis-tickets] r14439 - Test out freeing on simple cloned objects, do they

Paul Ramsey pramsey at cleverelephant.ca
Thu Nov 26 06:34:43 PST 2015


Author: pramsey
Date: 2015-11-26 06:34:42 -0800 (Thu, 26 Nov 2015)
New Revision: 14439

Modified:
   trunk/liblwgeom/cunit/cu_misc.c
Log:
Test out freeing on simple cloned objects, do they 
obey the read-only command? ref #3246


Modified: trunk/liblwgeom/cunit/cu_misc.c
===================================================================
--- trunk/liblwgeom/cunit/cu_misc.c	2015-11-26 13:00:21 UTC (rev 14438)
+++ trunk/liblwgeom/cunit/cu_misc.c	2015-11-26 14:34:42 UTC (rev 14439)
@@ -138,7 +138,24 @@
 	lwgeom_free(geomgrid);		
 }
 
+static void test_clone(void)
+{
+	static char *wkt = "GEOMETRYCOLLECTION(MULTIPOLYGON(((0 0, 10 0, 10 10, 0 10, 0 0))),POINT(1 1),LINESTRING(2 3,4 5))";
+	LWGEOM *geom1 = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_ALL);
+	LWGEOM *geom2;
+	
+	/* Free in "backwards" order */
+	geom2 = lwgeom_clone(geom1);
+	lwgeom_free(geom1);
+	lwgeom_free(geom2);
 
+	/* Free in "forewards" order */
+	geom1 = lwgeom_from_wkt(wkt, LW_PARSER_CHECK_ALL);
+	geom2 = lwgeom_clone(geom1);
+	lwgeom_free(geom2);
+	lwgeom_free(geom1);
+}
+
 /*
 ** Used by the test harness to register the tests in this file.
 */
@@ -152,4 +169,5 @@
 	PG_ADD_TEST(suite, test_misc_area);
 	PG_ADD_TEST(suite, test_misc_wkb);
 	PG_ADD_TEST(suite, test_grid);
+	PG_ADD_TEST(suite, test_clone);
 }



More information about the postgis-tickets mailing list