Click here to Skip to main content
15,883,917 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Sort the list of files available in a folder. Pin
Richard MacCutchan21-Jun-11 2:03
mveRichard MacCutchan21-Jun-11 2:03 
GeneralRe: Sort the list of files available in a folder. Pin
lucky_122121-Jun-11 2:10
lucky_122121-Jun-11 2:10 
GeneralRe: Sort the list of files available in a folder. Pin
Richard MacCutchan21-Jun-11 2:59
mveRichard MacCutchan21-Jun-11 2:59 
AnswerRe: Sort the list of files available in a folder. Pin
వేంకటనారాయణ(venkatmakam)21-Jun-11 3:05
వేంకటనారాయణ(venkatmakam)21-Jun-11 3:05 
QuestionQuestion about Getting Main Icon using Findresource() Pin
lek25820-Jun-11 21:51
lek25820-Jun-11 21:51 
AnswerRe: Question about Getting Main Icon using Findresource() Pin
Richard MacCutchan21-Jun-11 2:01
mveRichard MacCutchan21-Jun-11 2:01 
AnswerRe: Question about Getting Main Icon using Findresource() Pin
MicroVirus21-Jun-11 5:50
MicroVirus21-Jun-11 5:50 
Questionproblem while freeing a link list within a vector structure [modified] Pin
Madan Chauhan20-Jun-11 21:27
Madan Chauhan20-Jun-11 21:27 
Hi all.
I have a link list in a vector structure. It throws exception while freeing first node of the list. This is the sample code-


//////////Declaration//////
typedef struct _TEST_STRUCT
{
	TCHAR _tchTemp[MAX_PATH];
	__int64 i64Temp;
	DWORD dwTemp;
	_TEST_STRUCT *Next;
}TEST_STRUCT;

typedef struct _TEST_VECTORST
{
	int nVal;
	TEST_STRUCT m_ListInVector;

}TEST_VECTORST;

std::vector<TEST_VECTORST> m_StVector; 
////////////////////////////////////////////////////
/////////Fill Structure//////////////
        
	CString csVal = L"";
	csVal         = L"hello";
	for (int i = 0; i < 2; i++)
	{
		memset (&wVectorSt, 0x00, sizeof(TEST_VECTORST));
		ptrList = NULL;
		wVectorSt.nVal = i + 1;
		int j = 0;
		while (j<10)
		{
			if (ptrList == NULL)
			{
				ptrTemp = (TEST_STRUCT*)calloc(1,sizeof(TEST_STRUCT));
				_tcscpy(ptrTemp->_tchTemp, csVal);
				ptrTemp->dwTemp = 10+j;
				ptrTemp->i64Temp = 100+j;
				ptrTemp->Next = NULL;
				ptrCurrent = ptrList = ptrTemp;
			}
			else
			{
				ptrTemp = (TEST_STRUCT*)calloc(1,sizeof(TEST_STRUCT));
				_tcscpy(ptrTemp->_tchTemp, csVal);
				ptrTemp->dwTemp = 10+j;
				ptrTemp->i64Temp = 100+j;
				ptrTemp->Next = NULL;
				ptrCurrent->Next = ptrTemp;
				ptrCurrent       = ptrTemp;

			}
			j ++;
		}
		memcpy(&wVectorSt.m_ListInVector, ptrList, sizeof(TEST_STRUCT));
		m_StVector.push_back (wVectorSt);
	}
	//////Free m_StVector.m_ListInVector////
	for (int i = 0; i<m_StVector.size(); i++)
	{
		ptrList = m_StVector[i].m_ListInVector.Next;
		while (ptrList != NULL)
		{
			ptrTemp = ptrList;
			ptrList = ptrList->Next;
			free(ptrTemp);
			ptrTemp = NULL;
		}
	}  
All the nodes become free but one that is very first  node in the list does not free.
if i take  start to free from first node like- ptrList = &m_StVector[i].m_ListInVector;

then it throws exception immidiately and does not free any node...

Please give me some idea...


Thanks


modified on Tuesday, June 21, 2011 4:17 AM

AnswerRe: problem while freeing a link list within a vector structure Pin
CPallini20-Jun-11 22:12
mveCPallini20-Jun-11 22:12 
AnswerRe: problem while freeing a link list within a vector structure Pin
Stefan_Lang21-Jun-11 0:35
Stefan_Lang21-Jun-11 0:35 
GeneralRe: problem while freeing a link list within a vector structure Pin
Madan Chauhan21-Jun-11 1:07
Madan Chauhan21-Jun-11 1:07 
GeneralRe: problem while freeing a link list within a vector structure Pin
Stefan_Lang21-Jun-11 1:27
Stefan_Lang21-Jun-11 1:27 
AnswerRe: problem while freeing a link list within a vector structure Pin
CPallini21-Jun-11 1:15
mveCPallini21-Jun-11 1:15 
QuestionRe: problem while freeing a link list within a vector structure Pin
David Crow21-Jun-11 4:04
David Crow21-Jun-11 4:04 
QuestionI am using VC++ coding,Can any one help me? Pin
lucky_122120-Jun-11 21:14
lucky_122120-Jun-11 21:14 
AnswerRe: I am using VC++ coding,Can any one help me? Pin
CPallini20-Jun-11 22:10
mveCPallini20-Jun-11 22:10 
AnswerRe: I am using VC++ coding,Can any one help me? Pin
Cool_Dev20-Jun-11 22:18
Cool_Dev20-Jun-11 22:18 
QuestionConverting char array to CSting Pin
VCProgrammer20-Jun-11 1:43
VCProgrammer20-Jun-11 1:43 
AnswerRe: Converting char array to CSting Pin
Pete O'Hanlon20-Jun-11 1:54
mvePete O'Hanlon20-Jun-11 1:54 
GeneralRe: Converting char array to CSting [modified] Pin
Albert Holguin20-Jun-11 4:36
professionalAlbert Holguin20-Jun-11 4:36 
GeneralRe: Converting char array to CSting Pin
Pete O'Hanlon20-Jun-11 6:10
mvePete O'Hanlon20-Jun-11 6:10 
AnswerRe: Converting char array to CSting Pin
CPallini20-Jun-11 1:55
mveCPallini20-Jun-11 1:55 
AnswerRe: Converting char array to CSting Pin
Rajesh R Subramanian20-Jun-11 3:54
professionalRajesh R Subramanian20-Jun-11 3:54 
Question[Win32]Add context menu to edit control Pin
Member 296547120-Jun-11 1:24
Member 296547120-Jun-11 1:24 
AnswerRe: [Win32]Add context menu to edit control Pin
CPallini20-Jun-11 1:58
mveCPallini20-Jun-11 1:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.