Skip to content

Commit 5bb3ffe

Browse files
committed
Free the linked polygon.
After reading the FFI literature closely, it may be wise to use the built-in function from H3 to destroy linked polygons. We may avoid a memory leak this way.
1 parent 94808ad commit 5bb3ffe

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/h3/bindings/private.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ module Private
88
extend H3::Bindings::Base
99

1010
attach_function :compact, [H3IndexesIn, H3IndexesOut, :size], :bool
11+
attach_function :destroy_linked_polygon, :destroyLinkedPolygon, [LinkedGeoPolygon], :void
1112
attach_function :geo_to_h3, :geoToH3, [GeoCoord, Resolution], :h3_index
1213
attach_function :h3_indexes_from_unidirectional_edge,
1314
:getH3IndexesFromUnidirectionalEdge,

lib/h3/regions.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,8 @@ def h3_set_to_linked_geo(h3_indexes)
142142
Bindings::Private.h3_set_to_linked_geo(h3_set, h3_indexes.size, linked_geo_polygon)
143143

144144
extract_linked_geo_polygon(linked_geo_polygon).first
145+
ensure
146+
Bindings::Private.destroy_linked_polygon(linked_geo_polygon)
145147
end
146148

147149
private

0 commit comments

Comments
 (0)