I am having trouble with a piece of code. It works about 50% of the time. I have a struct defined as
struct strSCs{
char szCampaignName[20]; //campaign running on IP address
char szIPAddress[20];
char szIPAddressSelf[30]; //ip address that SC thinks it is
int iAbandonRateTarget;
int iAbandonRateCurrent;
int iNumRingsNoAnswer;
char szOnDate[20];
char szOnTime[20];
char szSCUser[15];
char szMinutesLeft[10];
char szMessageFile[80]; //message for this camp
int iValue; //this is for the listing on the uir
int iAutodialerLines; //lines used as autodialer
int iAgents; //agents logged on
int iHandle; //TCP handle
char szRandom[20];
char szCallerIDNum[20]; //from SC
char szCodec[5]; //from SC
int iCampDoneFlag;
int iMonitorOn; //0=monitor off 1 = monitor on
time_t timeHeartbeat; //last heartbeat
int iDigitsInPhone; //number of digits to dial
int iSCOffset; //this is the offset from 15900 that this camp is running
IniText itScript; //handle for the script
// char *pszScript; //pointer to the script
char szScript[15000]; //was 5k now it is 15k
int hScript;
IniText itFields; //handle for the fields
// char *pszFields; //pointer to the fields
char szFields[1000];
int hFields;
IniText itResults; //handle for the results
// char *pszResults; //pointer to the results
char szResults[5500];
int hResults;
int iP2P; //use P2P
int iServer; //use server
int iP2PHandle; //handle for SC to Gateway in P2P
int iNextAgentHandle; //next agent to use in a Pass
int iPersonalMessage; //flag to showwhether to use personal leave message 1=yes
int iAgentsTalking;
int iAgentsWrapping;
int iAMD; //flag to use AMD
int iAbandMessage; //use an abandon message
}strSCMember,*pstrSCMember,*ptrMem;
At some point in my main() code I am starting up a thread:
iRc = CmtScheduleThreadPoolFunction (DEFAULT_THREAD_POOL_HANDLE,
ThreadFunctionResultsWrite, (void *)ptrMem,
NULL);
It correctly starts up this function:
int CVICALLBACK ThreadFunctionResultsWrite (void *ptrMem)
{
IniText itR;
int iHandle;
char szBuf[255],*pszPtr;
char *pszResults;
char *pszMem;
pszResults=((struct strSCs*)ptrMem)->szResults;
if (strlen(pszResults)==0)
{
pszResults=((struct strSCs*)ptrMem)->szResults;
goto again;
}
Now, I always seem to get the buffer ptrMem being passed in correctly. I know because I can look at it with the debugger in the view memory. But SOMETIMES strlen(pszResults)==0. Now when I stop it in the thread and I look at ptrMem, I see the proper info in the view memory (which is just a string), but the first byte of pszResults equals x00. What is wrong or how can I go about fixing this?