Assume I dynamically allocate memory by creating the pointer p1:
int *p1 = malloc(10*sizeof(int));
Then I create a second pointer (p2) and make it point to the same block of memory:
int* p2;
p2 = p1;
Then I want to return the memory block back to the heap, so I give the following command:
free(p1);
My question is this: is the block of memory actually free now or is it still occupied because p2 is still pointing to it (i.e. blocking it)?