Quote Originally Posted by upload View Post
Any object allocated on the heap using malloc() does not go out existence until the program quits.
Even if free() is called, the pointer (dangling pointer) cannot be used to access the object, but the object still exists but may or may not be accessible. I am not sure about OS behavior but the memory will only be reclaimed after the program quits.

In the example below, both malloc() and free() are called and the pointer goes out of scope, yet the object still exists.

Code:
void test() {
    char *c = NULL;
    c = malloc(1);
    free(c);
}
The above is mostly false; because the freed area will be re-used sometimes.

Tim S.