I'm realy don't know what is happening with my code, I'm doing a legal memory allocation on one variable and the VC++ 6.0 simply create another variable on the same memory space.
The program is very large and I will not post the whole program, I will try to post the relevant part of the code:
I have 2 classes, lets talk about Class1 and Class2
on the main I have such a thing
int main()
{
...
Class1 *pClass1 = new Class1();
Class2 *pClass2 = new Class2();
Class2->Init();
...
}
class Class1
{
...
Class1()
{
Initialize();
}
void Initialize();
{
InitializeCriticalSection(&m_CriticalSection);
\\ Take a look on this variable
ThreadParam * param = new ThreadParam();
if(param != NULL)
{
param->Done = FALSE;
param->pCriticalSection = &m_CriticalSection;
// speciic on this;
param->List = m_List;
m_hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadFunction),(LPVOID)param,&m_ThreadID);
}
}
...
};
class Class2
{
public:
...
void Init()
{
...
myFlag = FALSE;
...
}
...
private:
...
BOOL myFlag;
};
When I run the program:
1) The memory allocated to Class2::myFlag is the same of param->List, i.e.:
printf("Class2::myFlag %p",&Class2::myFlag )
Output = 00374[/color red]
printf("param->List %p", ¶m->List )
Output = 00374[/color red]
The same output.
I dont delete none of the classes and I have no delete on param at all.
Changing from new to malloc does the same behavior.
Can anyone tell me what's wrong? Is there any knwon issue about this strange behavior?
Thanks in advance.
Flavio.
The program is very large and I will not post the whole program, I will try to post the relevant part of the code:
I have 2 classes, lets talk about Class1 and Class2
on the main I have such a thing
int main()
{
...
Class1 *pClass1 = new Class1();
Class2 *pClass2 = new Class2();
Class2->Init();
...
}
class Class1
{
...
Class1()
{
Initialize();
}
void Initialize();
{
InitializeCriticalSection(&m_CriticalSection);
\\ Take a look on this variable
ThreadParam * param = new ThreadParam();
if(param != NULL)
{
param->Done = FALSE;
param->pCriticalSection = &m_CriticalSection;
// speciic on this;
param->List = m_List;
m_hThread = CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadFunction),(LPVOID)param,&m_ThreadID);
}
}
...
};
class Class2
{
public:
...
void Init()
{
...
myFlag = FALSE;
...
}
...
private:
...
BOOL myFlag;
};
When I run the program:
1) The memory allocated to Class2::myFlag is the same of param->List, i.e.:
printf("Class2::myFlag %p",&Class2::myFlag )
Output = 00374[/color red]
printf("param->List %p", ¶m->List )
Output = 00374[/color red]
The same output.
I dont delete none of the classes and I have no delete on param at all.
Changing from new to malloc does the same behavior.
Can anyone tell me what's wrong? Is there any knwon issue about this strange behavior?
Thanks in advance.
Flavio.