I have c++ library, functions of which are called from python side. One of the functions gets a pointer on an array, which on python side has values in [0:255] and defined as
seq1=numpy.array(image,dtype=numpy.uint8).flatten()
seq=numpy.zeros((w*h*3),dtype=numpy.uint8)
the function call goes as
myCppFunction(ctypes.c_void_p(seq.ctypes.data),
ctypes.c_void_p(seq1.ctypes.data),
...)
on C++ side the function defined as
void myCppFunction(ushort *seq, ushort *sequence1, ...)
When I simply print what I receive on C++ side as seq, sequence1, I'm getting values far above unsigned short range and zeros sequence is not filled with zeros. Compilation goes fine but a real run results in segmentation fault. Where I'm wrong?
ctypes.data"may contain data that is not aligned, or not in the correct byte-order… may not even be writable." In other words, even if it were auint16array, you can't just pass it to aushort *without checking anything.