data
in my_fnc
has to be treated as void**
to be able to extract the real data.
int my_fnc(void *data)
{
void** sredp = (void**)data;
str* obuf = (str*)srdep[0];
// The pointer that contains len can be obtained from srdep[1]
// The pointer that contains ri can be obtained from srdep[2]
}
Here's a simple program that illustrates that:
#include <stdio.h>
void foo(void* data)
{
void** realData = (void**)data;
void* p1 = realData[0];
void* p2 = realData[1];
void* p3 = realData[2];
printf("sredp[0]: %p\n", p1);
printf("sredp[1]: %p\n", p2);
printf("sredp[2]: %p\n", p3);
int a1 = *(int*)p1;
float a2 = *(float*)p2;
double a3 = *(double*)p3;
printf("a1: %d\n", a1);
printf("a2: %f\n", a2);
printf("a3: %lf\n", a3);
}
int main()
{
int a1 = 10;
float a2 = 20.0f;
double a3 = 40.0;
void *sredp[3];
sredp[0] = &a1;
sredp[1] = &a2;
sredp[2] = &a3;
printf("sredp[0]: %p\n", sredp[0]);
printf("sredp[1]: %p\n", sredp[1]);
printf("sredp[2]: %p\n", sredp[2]);
foo(sredp);
}
Sample output from running the program:
sredp[0]: 0x28ac2c sredp[1]: 0x28ac28 sredp[2]: 0x28ac20 sredp[0]: 0x28ac2c sredp[1]: 0x28ac28 sredp[2]: 0x28ac20 a1: 10 a2: 20.000000 a3: 40.000000