The pointer will also be destroyed, but the address it contains will be valid until that region is freed. When you return from such a function you could return the value (i.e the address on the heap) but not the pointer it self.
Code:char *foo() { char *p = malloc( 16 * sizeof(char) ); if(!p) return NULL; return p; }