How to find the number of elements in a pointer to array from C?

#1
julia> D = GMT.ogrfeatures2GMTdataset(colomb);
ERROR: BoundsError: attempt to access 119-element Array{GMT.GMTdataset,1} at index [127]

The thing happens at an instruction like this unsafe_wrap(Array, x, np) and is cause by a wrong np but the whole thing comes from wrapping a C lib and fixing it implies find/fix the bug in the C side. However, Julia knows the size of x because it says there are 119-elements in it. So, how can I access to the same information? This would allow to solve the issue for now.

Thanks.

0 Likes

#2

Sorry, my confusion. The error come from another line.

0 Likes

#3

Try to answer the question:

0 Likes

#4

Thanks, that clang_getNumElements() seem that could be a good lead. But I was no clear in my second post. It turns out that the error doesn’t come from the unsafe_wrap() call but from an error in my julia code (now fixed).

0 Likes