P
Prafulla T
Is following correct way of deleting entries from stl hashset.
Will it create any memory corruption ?
One of my program uses this way and it is crashing in strange way but
purify or valgrind does not
show up anything. I am suspecting this piece of code as a problem.
Can anyone comment on it ?
for (hash_set<UserType*>::iterator hashIt = hashSet.begin();
hashIt != hashSet.end(); hashIt++)
{
UserType *pUserType = *hashIt;
hashIt++;
delete pUserType;
pUserType = NULL;
}
Will it create any memory corruption ?
One of my program uses this way and it is crashing in strange way but
purify or valgrind does not
show up anything. I am suspecting this piece of code as a problem.
Can anyone comment on it ?
for (hash_set<UserType*>::iterator hashIt = hashSet.begin();
hashIt != hashSet.end(); hashIt++)
{
UserType *pUserType = *hashIt;
hashIt++;
delete pUserType;
pUserType = NULL;
}