I need to learn how to handle char** in the C ++ method below using Python types. I did great calls to other methods that only need single pointers using create_string_buffer() , but this method requires a pointer to an array of pointers.
ladybugConvertToMultipleBGRU32( LadybugContext context, const LadybugImage * pImage, unsigned char** arpDestBuffers, LadybugImageInfo * pImageInfo )
How to create a pointer to an array of six create_string_buffer(7963648) buffers in ctypes to pass this C ++ method to write?
arpDestBuffers = pointer to [create_string_buffer(7963648) for i in xrange(6)]
Thanks for any help.
Both of the answers below work. I just did not understand that I had another problem in my code that prevented me from immediately seeing the results. The first example is the same as Luke wrote:
SixBuffers = c_char_p * 6 arpDestBuffers = SixBuffers( *[c_char_p(create_string_buffer(7963648).raw) for i in xrange(6)] )
Second example coming from omu_negru answer:
arpDestBuffers = (POINTER(c_char) * 6)() arpDestBuffers[:] = [create_string_buffer(7963648) for i in xrange(6)]
Both are accepted by the function and overwritten. Entering print repr(arpDestBuffers[4][:10]) before and after the function call gives:
'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00' '\x15\x10\x0e\xff\x15\x10\x0e\xff\x14\x0f'
which indicates that the function has successfully overwritten the buffer with data.
source share