Dear Experts,
It is urgent to know how to deal with the following case:
=========
1. data struct definition:
typedef struct datatype
{
int (*f) (int *a, char *b);
} DataType;
2. Functions definition:
int f1 (int *a, char *b)
{
int c;
d=a+b;
return c;
}
int f2 (int *a, char *b)
{
int c;
d=a-b;
return c;
}
int f3 (int *a, char *b)
{
int c;
d=a*b;
return c;
}
3. Use of the struct
main()
{
DataTyppe *dP;
int i;
int output;
if (i==1) dP->f=f1;
else if (i==2) dP->f=f2;
else dP->f=f3;
}
Question: how to memTab[] for the dP->f ?
I found the problem: if I allocates memory for "dP" with "memTab[]", it is able to be used for some variables inside "dP", but if a function inside, the OMAP DSP side have no idea where is the "dP->f"? and the program will crash sometimes, or give wrong result.
How to deal with this thing? thanks
Dave