Skip to content

Commit

Permalink
take ownership of triangulation memory
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Isensee committed Jan 24, 2024
1 parent 15a8c13 commit 0bace1a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/triangulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -183,31 +183,31 @@ function earcut_triangulate(polygon::Vector{Vector{Point{2,Float64}}})
len = UInt32(length(lengths))
array = ccall((:u32_triangulate_f64, libearcut), Tuple{Ptr{GLTriangleFace},Cint},
(Ptr{Ptr{Float64}}, Ptr{UInt32}, UInt32), polygon, lengths, len)
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2])
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2]; own=true)
end

function earcut_triangulate(polygon::Vector{Vector{Point{2,Float32}}})
lengths = map(x -> UInt32(length(x)), polygon)
len = UInt32(length(lengths))
array = ccall((:u32_triangulate_f32, libearcut), Tuple{Ptr{GLTriangleFace},Cint},
(Ptr{Ptr{Float32}}, Ptr{UInt32}, UInt32), polygon, lengths, len)
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2])
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2]; own=true)
end

function earcut_triangulate(polygon::Vector{Vector{Point{2,Int64}}})
lengths = map(x -> UInt32(length(x)), polygon)
len = UInt32(length(lengths))
array = ccall((:u32_triangulate_i64, libearcut), Tuple{Ptr{GLTriangleFace},Cint},
(Ptr{Ptr{Int64}}, Ptr{UInt32}, UInt32), polygon, lengths, len)
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2])
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2]; own=true)
end

function earcut_triangulate(polygon::Vector{Vector{Point{2,Int32}}})
lengths = map(x -> UInt32(length(x)), polygon)
len = UInt32(length(lengths))
array = ccall((:u32_triangulate_i32, libearcut), Tuple{Ptr{GLTriangleFace},Cint},
(Ptr{Ptr{Int32}}, Ptr{UInt32}, UInt32), polygon, lengths, len)
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2])
return unsafe_wrap(Vector{GLTriangleFace}, array[1], array[2]; own=true)
end

best_earcut_eltype(x) = Float64
Expand Down

0 comments on commit 0bace1a

Please sign in to comment.