Im using new to allocate memory and initialize a variable of a class.
Here's the code used:
New operator:
ptrIssuResrc = new IssuResource();
-----------------------------------
Class definition:
class IssuResource
{
public:
// constructor: create a IssueResource object
IssuResource(void)
{
lastUpdatedResource = 0;
}
UINT16 lastUpdatedResource;
UINT32 conn_list[MAX_CONNECTION];
bool addConnResourceToList(UINT32);
Using ptrIssuRescr
:
class IssuResource *issuResrcPtr = NULL;
issuResrcPtr = card->ptrIssuResrc;
class IssuResource *ptrIssuResrc = card->ptrIssuResrc;
ptrIssuResrc->addConnResourceToList(connection->getLcn());
I'm facing some memory corruption due to this code, have narrowed down. Please help me with whats wrong here? How can I ensure there is no memory coruuption? I have moved the new operator to another location in the code and it worked fine. But I still need to ensure that wont cause new issues.
TIA