I have a struct:
struct Foo
{
int x;
int *ptr;
void *ptr2;
};
If I allocate memory for ptr using:
ptr = malloc(sizeof(int));
and later I want to it to point it to something else that already has memory allocated for it, do I need to free ptr before doing:
ptr = *other_variable;