Skip to content

Commit

Permalink
fixing memory leaks with GEOS geometry #13
Browse files Browse the repository at this point in the history
  • Loading branch information
behrisch committed Jan 24, 2024
1 parent f23d336 commit 8ffdadd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/microsim/transportables/MSPModel_JuPedSim.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -455,13 +455,16 @@ MSPModel_JuPedSim::createGeometryFromShape(PositionVector shape, std::string sha
} else {
WRITE_WARNINGF(TL("Polygon '%' has been dilated as it is just a segment."), shapeID);
}
GEOSGeometry* lineString = GEOSGeom_createLineString(coordinateSequence);
GEOSGeometry* lineString = GEOSGeom_createLineString(GEOSCoordSeq_clone(coordinateSequence));
GEOSGeom_destroy(polygon);
polygon = GEOSBufferWithStyle(lineString, GEOS_BUFFERED_SEGMENT_WIDTH, GEOS_QUADRANT_SEGMENTS, GEOSBUF_CAP_ROUND, GEOSBUF_JOIN_ROUND, GEOS_MITRE_LIMIT);
GEOSGeom_destroy(lineString);
} else {
if (isInternalShape) {
WRITE_WARNINGF(TL("Polygon on junction '%' has been replaced by its convex hull as it is not simple."), shapeID);
polygon = GEOSConvexHull(polygon);
GEOSGeometry* hull = GEOSConvexHull(polygon);
GEOSGeom_destroy(polygon);
polygon = hull;
} else {
WRITE_WARNINGF(TL("Polygon '%' will be skipped as it is not simple."), shapeID);
polygon = nullptr;
Expand Down

0 comments on commit 8ffdadd

Please sign in to comment.