I\'m investigating a memory leak and from what I see, the problem looks like this:
int main(){ char *cp = 0; func(cp); //code delete[] cp; } voi
You are assigning cp the value of the allocated memory. However, that's a variable on the stack: a copy of the cp in main! cp is local to the function you're in.
cp
What you want is a reference:
void func(char *& cp)
This will alias cp to be the parameter passed in.