I created a small test in order to create memory leaks and testing the leaks in terminal using leaks command. Now I encountered a strange behavior with the NULL. So any explanation why the other code leaks, and the other one doesn't? Aren't they really the same?
int main(void)
{
char *ptr;
char *btr;
ptr = NULL;
btr = (char*)malloc(4);
btr = ptr;
while (1)
;
return (0);
}
// LEAKS
int main(void)
{
char *btr;
btr = (char*)malloc(4);
btr = NULL;
while (1)
;
return (0);
}
//NO LEAKS ?? why