This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
[Dumb question] Is this a memory leak ?
- To: gcc at gcc dot gnu dot org
- Subject: [Dumb question] Is this a memory leak ?
- From: biswapesh dot chattopadhyay at bt dot com
- Date: Thu, 21 Dec 2000 10:23:30 -0000
Hi
Please excuse my ignorance - what happens in the following code?
char *trim(char *str)
{
return (str + 3);
}
void f()
{
char *str = strdup("1234567890");
str = trim(str);
// Do other stuff
free(str);
return;
}
Basically, I'm free()-ing an address which is different from the one I
malloc()-ed.
Thanks.
Biswa.