I wrote the following function. i want to return fbCodeAddr and tmpAddr to the main function.
How to do this?
Function is as follows;
void fbExeCode(int BldCnt)
{
// for(int BldCnt=0;BldCnt<fbdStepno; BldCnt++)
{
char *fbCodeAddr;
char *tmpAddr=0;
char *buffer;
int n;
fbCodeAddr=(char *)malloc(1024);
int stack=0;
int totalPin=0;
for(int fb=0;fb<fbnodeLst.size();fb++)
{
totalPin+=fbnodeLst[fb].fbInfo->fb_str->pinCnt;
}
//printf("BLD:%d PIN:%d\n ", BldCnt,totalPin);
memcpy(fbCodeAddr, (char *)&BldCnt,4);
memcpy(fbCodeAddr+4, (char *)&stack,4);
memcpy(fbCodeAddr+8, (char *)&totalPin,4);
tmpAddr = fbCodeAddr+12;
// printf("ORDER SIZE:%d\n", orderList.size());
for(int OL=0; OL<orderList.size();++OL)
{
tmpAddr+=4;
memcpy(tmpAddr, (char *)&orderList[OL].fbCode,4);
for(int ip=0; ip<orderList[OL].ipAdr.size();++ip)
{
tmpAddr+=4;
memcpy(tmpAddr, (char *)&orderList[OL].ipAdr[ip],4);
// printf("IP Adress %d:0x%x\n" ,ip+1, orderList[OL].ipAdr[ip]);
}
for(int op=0;op<orderList[OL].opAdr.size();++op)
{
tmpAddr+=4;
memcpy(tmpAddr, (char *)&orderList[OL].opAdr[op],4);
//printf("O/P Adress :0x%x\n\n", orderList[OL].opAdr[op]);
}
}
printf("Total bytes Used:%d Bytes\n", tmpAddr+4-fbCodeAddr);
printf("fbcodeAddr:0x%x \n", *(fbCodeAddr+8));
}
}