[geos-commits] [SCM] GEOS branch main updated. ea0163df520e6aaa50e3d935cf132625ef79b60f
git at osgeo.org
git at osgeo.org
Tue Mar 4 10:57:46 PST 2025
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GEOS".
The branch, main has been updated
via ea0163df520e6aaa50e3d935cf132625ef79b60f (commit)
from 2d7cb470a555b321d1a299b5de4208c9da2aefe4 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit ea0163df520e6aaa50e3d935cf132625ef79b60f
Author: Paul Ramsey <pramsey at cleverelephant.ca>
Date: Tue Mar 4 10:51:39 2025 -0800
Remove memory leak from PolygonNodeConverterTest
diff --git a/tests/unit/operation/relateng/PolygonNodeConverterTest.cpp b/tests/unit/operation/relateng/PolygonNodeConverterTest.cpp
index 2d3ee22d7..d50988de7 100644
--- a/tests/unit/operation/relateng/PolygonNodeConverterTest.cpp
+++ b/tests/unit/operation/relateng/PolygonNodeConverterTest.cpp
@@ -31,6 +31,28 @@ namespace tut {
// Common data used by all tests
struct test_polygonnodeconverter_data {
+ std::deque<std::unique_ptr<Coordinate>> coordQue;
+ std::deque<std::unique_ptr<NodeSection>> nsQue;
+
+ Coordinate* newCoordinate(double x, double y)
+ {
+ coordQue.emplace_back(new Coordinate(x, y));
+ return coordQue.back().get();
+ }
+
+ NodeSection* section(int ringId, double v0x, double v0y, double nx, double ny, double v1x, double v1y)
+ {
+ NodeSection *ns = new NodeSection(
+ true, Dimension::A, 1, ringId,
+ nullptr, false,
+ newCoordinate(v0x, v0y),
+ Coordinate(nx, ny),
+ newCoordinate(v1x, v1y)
+ );
+ nsQue.emplace_back(ns);
+ return nsQue.back().get();
+ }
+
NodeSection* sectionShell(double v0x, double v0y, double nx, double ny, double v1x, double v1y) {
return section(0, v0x, v0y, nx, ny, v1x, v1y);
}
@@ -39,17 +61,12 @@ struct test_polygonnodeconverter_data {
return section(1, v0x, v0y, nx, ny, v1x, v1y);
}
- NodeSection* section(int ringId, double v0x, double v0y, double nx, double ny, double v1x, double v1y) {
- return new NodeSection(true, Dimension::A, 1, ringId, nullptr, false,
- new Coordinate(v0x, v0y), Coordinate(nx, ny), new Coordinate(v1x, v1y));
- }
-
std::vector<const NodeSection*>
toPtrVector(const std::vector<std::unique_ptr<NodeSection>>& input)
{
std::vector<const NodeSection*> vec;
for(std::size_t i = 0, n = input.size(); i < n; ++i) {
- vec.emplace_back(input[i].get());
+ vec.push_back(input[i].get());
}
return vec;
}
@@ -67,6 +84,7 @@ struct test_polygonnodeconverter_data {
}
return true;
}
+
void sort(std::vector<const NodeSection*>& ns) {
// Comparator lambda for sort support
@@ -80,15 +98,6 @@ struct test_polygonnodeconverter_data {
std::sort(ns.begin(), ns.end(), comparator);
}
- void
- freeNodeSections(std::vector<const NodeSection*>& ns) {
- for (std::size_t i = 0; i < ns.size(); i++) {
- delete ns[i]->getVertex(0);
- delete ns[i]->getVertex(1);
- delete ns[i];
- }
- }
-
void
checkConversion(std::vector<const NodeSection *>& input,
std::vector<const NodeSection *>& expected)
@@ -96,14 +105,6 @@ struct test_polygonnodeconverter_data {
auto actual = PolygonNodeConverter::convert( input );
auto actualPtr = toPtrVector(actual);
bool isEqual = checkSectionsEqual(actualPtr, expected);
- freeNodeSections(input);
- freeNodeSections(expected);
- /*
- if (! isEqual) {
- System.out.println("Expected:" + formatSections(expected));
- System.out.println("Actual:" + formatSections(actual));
- }
- */
ensure("checkConversion", isEqual);
}
-----------------------------------------------------------------------
Summary of changes:
.../relateng/PolygonNodeConverterTest.cpp | 47 +++++++++++-----------
1 file changed, 24 insertions(+), 23 deletions(-)
hooks/post-receive
--
GEOS
More information about the geos-commits
mailing list