Does the code compile without errors and warnings? I Don't think so. Increasing the compiler warn level may help you finding some problems (Project settings with VC).
pData->URL = 0 ;
This will initialize the first element of the array, but not the others. Possible soure for problems.
TempURL = StrDupA(pURL) ;
is not defined (compiler error).
returns a pointer to allocated memory and must be freed later using
. Without freeing, you have memory leaks.
pData->URL[dwIndex] = (PCHAR)TempURL ;
This generates a compiler warning, because
is not initialized. Your code will probably crash.
dwTotalNumberOfURL = dwIndex ;
is not defined (compiler error). Not necessary. Can use
is allocated but not freed. Another memory leak.
DownloadFile(pData->URL, pData->DestinationPath) ;
is an array of
pointers. You did not show the code for
but it may be expects a
. If it expects a
it would be OK.
You should initialize dwIndex, fill your struct with NULL bytes, and free up memory at the end of your function:
DWORD dwIndex = 0;
pData = (PMAINDATA)malloc(sizeof(MAINDATA)) ;
pData->URL[dwIndex] = (PCHAR)StrDupA(pURL) ;
for (DWORD i = 0; i < dwIndex && pData->URL[dwIndex]; i++)
I did not know if I found all. There are too many.