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
void func(char *cp){
cp = new char[100];
}
In this function, char *cp is a "pointer being passed by copy" what means that they are pointing to the same memory address but they are not the same pointer. When you change the pointer inside, making it to point to somewhere else, the original pointer that has been passed will keep pointing to 0.