B
BigBrian
I realize this isn't the best code, but I'm doing maintenance on a
legcy system that has something similar to the following...
class Foo
{
//...
}
int main()
{
char * p_char = new char[5000];
// p_char gets filled with data read from a socket
Foo * p_foo = (Foo *) p_char;
// p_foo gets used here...
delete p_foo;
}
Assuming Foo is smaller than 5000 * sizeof(char), will this result in a
memory leak? Or will the call to delete know that more memory was
allocated than sizeof(Foo), and do the right thing?
legcy system that has something similar to the following...
class Foo
{
//...
}
int main()
{
char * p_char = new char[5000];
// p_char gets filled with data read from a socket
Foo * p_foo = (Foo *) p_char;
// p_foo gets used here...
delete p_foo;
}
Assuming Foo is smaller than 5000 * sizeof(char), will this result in a
memory leak? Or will the call to delete know that more memory was
allocated than sizeof(Foo), and do the right thing?