You will need to pass the data length from MyFunction . Also, make sure you know who allocates memory and who frees it. There are various templates for this. Quite often I saw:
int MyFunction(unsigned char* data, size_t* datalen)
Then you select the data and pass the datalen. The result (int) should then indicate if your buffer (data) was long enough ...
Daren thomas
source share