19 Jun
2006
19 Jun
'06
15:05
On Monday 19 June 2006 22:56, Verdi March wrote:
On Monday 19 June 2006 22:09, Jerry Feldman wrote:
No. That is because the pointer is available in main. If you allocate memory inside of a function, and return from that function without freeing that memory or without providing a pointer to that memory, that is unreachable.
I tried the above with a simpler testcase:
int main() { int *iptr iptr (int *) malloc(sizeof(int));
This should be: iptr = (int *) malloc(sizeof(int));
return 0; }
and valgrind still detect a memory leak. Obviously I hold a pointer (iptr) to the allocated memory, or do I misunderstand your explanation?