rendered paste bodylong SomeFunction(HLINE hCurrentHandle,char* szAgentID) { LPLINEAGENTGROUPLIST lpAgentGroupList; LPLINEAGENTGROUPENTRY lpAgentGroupEntry; long rCode; if((lpAgentGroupList = (LPLINEAGENTGROUPLIST)malloc(sizeof(LINEAGENTGROUPLIST) + 1 * sizeof(LINEAGENTGROUPENTRY) + ((lstrlen(szAgentID) + 1) * sizeof(TCHAR))))== NULL) return 1; lpAgentGroupList->dwTotalSize = (sizeof(LINEAGENTGROUPLIST) + 1 * sizeof(LINEAGENTGROUPENTRY) + ((lstrlen(szAgentID) + 1) * sizeof(TCHAR))); lpAgentGroupList->dwUsedSize = lpAgentGroupList->dwTotalSize; lpAgentGroupList->dwNeededSize = lpAgentGroupList->dwTotalSize; lpAgentGroupList->dwNumEntries = 1; lpAgentGroupList->dwListSize = sizeof(LINEAGENTGROUPENTRY) * 1 + ((lstrlen(szAgentID) + 1) * sizeof(TCHAR)); lpAgentGroupList->dwListOffset = sizeof(LINEAGENTGROUPLIST); lpAgentGroupEntry = (LPLINEAGENTGROUPENTRY)(((LPBYTE)lpAgentGroupList) + lpAgentGroupList->dwListOffset); lpAgentGroupEntry->GroupID.dwGroupID1 = 0; lpAgentGroupEntry->GroupID.dwGroupID2 = 0; lpAgentGroupEntry->GroupID.dwGroupID3 = 0; lpAgentGroupEntry->GroupID.dwGroupID4 = 0; lpAgentGroupEntry->dwNameSize = (lstrlen(szAgentID) + 1) * sizeof(TCHAR); lpAgentGroupEntry->dwNameOffset = lpAgentGroupList->dwListOffset + sizeof(LINEAGENTGROUPENTRY); // Copy AgentID into buffer lstrcpy((LPTSTR)(((LPBYTE)lpAgentGroupList) + lpAgentGroupEntry->dwNameOffset),szAgentID); rCode = lineSetAgentGroup(hCurrentHandle,0,lpAgentGroupList); // I would'nt free the block right away unless the function has failed. This is an asynchronous function, // rather wait for a LINE_REPLY and then free it when you know it is completed. free(lpAgentGroupList); return 0;}