Name: Anonymous 2011-01-18 22:44
#include <stdlib.h>
int * b;
int main(void)
{
int * a = NULL;
a = (int *) malloc(sizeof(int));
b = &a;
free(b);
return 0;
}Would this result in a memory leak? If yes, why?
#include <stdlib.h>
int * b;
int main(void)
{
int * a = NULL;
a = (int *) malloc(sizeof(int));
b = &a;
free(b);
return 0;
}void* only when you have to dereference it.void*.void*, you assign the pointer to another pointer with the correct type instead of working on the casted void*.