Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

malloc() and free()

Name: Anonymous 2011-01-18 22:44

#include <stdlib.h>

int * b;

int main(void)
{
    int * a = NULL;
    a = (int *) malloc(sizeof(int));
    b = &a;
    free(b);
    return 0;
}


Would this result in a memory leak? If yes, why?

Name: Anonymous 2011-01-19 20:24

>>30
Once a process has ended, the kernel frees all the memory it allocated for it and that includes heap memory. Now go learn about memory management before making random assertions about the operating system you've been using for two weeks.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List