i have a bunch of data i want to pass to CreateThread. i created a struct as per the msdn documentation. here it is:

typedef struct ThreadRecvData
{
	std::list<char> data;
	Ogre::String addr;
	unsigned long port;
} THREADRECVDATA, *PTHREADRECVDATA;

then i initialise the struct, again as per the msdn documentation:

PTHREADRECVDATA pThreadRecvData;
pThreadRecvData = (PTHREADRECVDATA) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(THREADRECVDATA));
pThreadRecvData->addr = "123";
pThreadRecvData->port = 123;
pThreadRecvData->data.push_back('x');

i get a crash at pThreadRecvData->data.push_back('x').

can anyone help ?

thank you.

You probably can't use HeapAlloc() to allocate memory for pThreadRecvData because std::list allocated memory from the standard heap using new operator. Replace HeapAlloc() with new and retest.

You probably can't use HeapAlloc() to allocate memory for pThreadRecvData because std::list allocated memory from the standard heap using new operator. Replace HeapAlloc() with new and retest.

i used new and yes it does indeed work. i wanted really to understand what was happening - so thanks for the explanation.