There is nothing wrong with your understanding with heap memory (or at least, I don't think there is) - Your confusion seems to be with the fact that when the function goes finishes, the variable "p"...
Type: Posts; User: Click_here
There is nothing wrong with your understanding with heap memory (or at least, I don't think there is) - Your confusion seems to be with the fact that when the function goes finishes, the variable "p"...
I think what you are wanting to do is something like this:
void function(int **p)
{
int*y=malloc(4);
*p=y;
return;