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 2:43

>>6
>>1

Shouldn't it also be: if(b == NULL) free(b);

That's what I'd do mai niggas. Keep it real yo.

Name: Anonymous 2011-01-19 2:44

>>8
haha I meant !=, I swear

Name: Anonymous 2011-01-19 3:19

>>9
No. Fuck you. free(NULL) is no-op on any decent compiler.

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