Skip to content

Commit dc633d7

Browse files
committed
mem allocation
1 parent 4ea3ec1 commit dc633d7

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

bindings/java/src/main/java/com/cadoodlecad/manifold/ManifoldBindings.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ public ManifoldBindings(File cacheDirectory) throws Exception {
292292
// ManifoldVec2 is {double x, double y} = 16 bytes
293293
load("manifold_polygons_get_point", MemoryLayout.structLayout(ValueLayout.JAVA_DOUBLE, ValueLayout.JAVA_DOUBLE),
294294
ValueLayout.ADDRESS, ValueLayout.JAVA_INT, ValueLayout.JAVA_INT);
295+
// ManifoldPolygons* manifold_alloc_polygons();
296+
load("manifold_alloc_polygons", ValueLayout.ADDRESS);
297+
295298
// ===== Analysis =====
296299

297300
// double manifold_volume(ManifoldManifold* m);
@@ -492,9 +495,9 @@ public ManifoldBindings(File cacheDirectory) throws Exception {
492495
public ArrayList<double[][]> slice(MemorySegment m, double height) throws Throwable {
493496
MemorySegment polygons = null;
494497
try (Arena arena = Arena.ofConfined()) {
495-
MemorySegment mem = arena.allocate(256); // ManifoldPolygons opaque mem
498+
MemorySegment mem = (MemorySegment) functions.get("manifold_alloc_polygons").invoke();
496499
polygons = (MemorySegment) functions.get("manifold_slice").invoke(mem, m, height);
497-
500+
498501
long numContours = (long) functions.get("manifold_polygons_num_contour").invoke(polygons);
499502
ArrayList<double[][]> result = new ArrayList<double[][]>((int) numContours);
500503

0 commit comments

Comments
 (0)