
CodePudding user response:
Finally here no, p will be destroyed, immediately outside the main function can't access the pCodePudding user response:
If I add commented that a canCodePudding user response:
Can be added, and, in many of the functions, I observed, after release, variable variable is not set to NULL, that is to say after the release of the if (NULL==p) and must be set up, if you want to reuse the variable and pass NULL judgments can be a problemCodePudding user response:
After the release of the if (NULL==p) does not have to set upCodePudding user response:
File pointer in the procedure of our company are used once, after use will not free, until the end of the program, total feel very strange, destroyed the habit,
CodePudding user response:
In a statement after the release of the first line of code is added, no problem for certain, without words, in some cases may have a problemCodePudding user response:
The original poster described not clear, I detailed said:Free (p);
, then p=NULL;
Is to use p to behind the pointer can be judged whether has released!
You this example, p finally have no, so there's no need to assign it again!
For a pointer, as long as you will know how to use it, then with a null value is not a must!
CodePudding user response:
Release should connect address didn't also should need notCodePudding user response:
Delphi seem to have a freeAndNil similar,,, have no in c + + builder?