I am probably making a basic mistake here, but I just can't figure out why...
I am using a void* pointer in a class (hash table, as some of you probably know) to hold some information. At the end of the program, I delete the hash table, along with the void* pointers.
1. If a specific typecast is not made, the destructor of the object stored in the variable is not called. I guess this would be a normal behavior (rigth or wrong?).
2. When I make the typecast, the destructor is called, but still, I am getting memory leaks reports.
I am using MSVC++6 and I can't figgure out if this is an reporting error (I heard there are some) or is it just me...
Here is a sample:
inside the destructor of the hash table, I have:
Likesaid, in either case, memory leaks are reported. Anybody can give me a clue of what's happening or how to solve this(Zy, M.E.Slf)? The void pointer should remain as it is, since the data in the hashTable shouldn't have any importance to the HashTable itself.
Thanks! [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro
I am using a void* pointer in a class (hash table, as some of you probably know) to hold some information. At the end of the program, I delete the hash table, along with the void* pointers.
1. If a specific typecast is not made, the destructor of the object stored in the variable is not called. I guess this would be a normal behavior (rigth or wrong?).
2. When I make the typecast, the destructor is called, but still, I am getting memory leaks reports.
I am using MSVC++6 and I can't figgure out if this is an reporting error (I heard there are some) or is it just me...
Here is a sample:
Code:
class Hash {
void *data;
setMember(char* str,void *inData) {
...
data = inData;
}
}
class SomeClass
{ Hash ht;
...
}
bool SomeClass::SomeMember()
{ OtherClass* oc = new OtherClass();
ht->setMember(someString,oc);
return true; //!!! no deletion
}
inside the destructor of the hash table, I have:
Code:
Hash::~Hash()
{ if (data)
delete data; // does not call the destructor
//or
delete (OtherClass *)data; // destructor called.
}
Likesaid, in either case, memory leaks are reported. Anybody can give me a clue of what's happening or how to solve this(Zy, M.E.Slf)? The void pointer should remain as it is, since the data in the hashTable shouldn't have any importance to the HashTable itself.
Thanks! [red]Nosferatu[/red]
We are what we eat...
There's no such thing as free meal...
once stated: methane@personal.ro