Hi All;
I have problem with passing the data. Anyone please help!
I have something like this (I know it's long and need to pay closed attention.) Is there any way to check that the data is passed correctly? Yhank you very much!
Code:
typedef struct {
int re;
int im;
}CFIXED;
int BIT_REVERSE[4096];
void AccessData(CFIXED* f, int p, int* array)
{
// Doing something
}
void reverse_data(CFIXED* input, int* bit_reverse, int veclength)
{
//Doing something
}
void FillBuffer(unsigned char ware, void *data)
{
FILE *file_in;
// Open data file
file_in = fopen("test_in.dat", "rb");
if (file_in == NULL)
printf("error opening file \n");
// Read the data into the buffer data
fread(data, sizeof(CFIXED), 4096, file_in);
printf("*****Filling the buffer.***** \n");
fclose(file_in);
}
void ProcessAAT(void *data)
{
FILE *file_out;
void *buffer_ptr;
file_out = fopen("data_out.dat", "wb");
if(file_out == NULL)
printf("error opening file \n");
buffer_ptr = data;
AccessData(buffer_ptr, 12, REDUCE);
reverse_data(buffer_ptr, BIT_REVERSE, 4096);
// write to output file
fwrite(data, sizeof(CFIXED), 4096, file_out);
printf("****Running Process AAT ****\n");
fclose(file_out);
}
}
void Allocate(unsigned char ware, void *buf)
{
switch(ware)
{
case BBT:
FillBuffer(ware, buf);
break;
case AAT:
ProcessAAT(buf);
break;
}
}
void CheckPending(void *data)
{
Allocate(ID, data);
}
void DeAllocate(void)
{
// Doing something
}
void CallFunction(unsigned char ware, void *buf)
{
DeAllocate();
CheckPending(buf);
Allocate(ware, buf);
}
int main (void)
{
void * buffer;
buffer = malloc(sizeof(CFIXED)*4096);
CallFunction(BBT,buffer);
CallFunction(AAT, buffer);
}