I have to call from a C# application a C function (from a DLL) declared as:
void fillBuffer( uint8_t ** pData, uint32_t * size );
This function checks if pData
is not null and in case it fills the buffer with some fancy data. The variable size
it is used as input parameter to limit the number of bytes that will be written in pData
, and as output parameter to inform how many bytes have been actually written.
In case pData
is null, it will allocate the buffer itself and will return in size
the number of bytes allocated.
How I can declare and call this function from a C# application (avoiding unsafe
if possibile) in both scenarios (passing an already allocated buffer or letting it allocates for me)?