Article View: comp.std.c
Article #2064free()
From: Brian K. W. Hook
Date: Thu, 13 Dec 1990 14:04
Date: Thu, 13 Dec 1990 14:04
23 lines
986 bytes
986 bytes
Okay, I know this is going to be a stupid question to a lot of you, but I
am just a tad curious. According to the C-reference manuals, you pass
free a pointer to a block of memory that you want deallocate. Eg.
char *a;
a=malloc(80);
if (a) free(a);
Now what happens if, oh, you do THIS:
foo()
{
int x;
x=10;
if (x) free (&x);
}
I know that malloc uses heap space and that the local variables take up the
stack, so what happens? &x is NOT null so it will try to free it, so what
happens? Also, in a similar vein, are global variables allocated on the heap
or stack? All replies would be appreciated.
Technical Details
Message-ID:
<25898@uflorida.cis.ufl.EDU>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mcnc!gatech!uflorida!reef.cis.ufl.edu!jdbShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mcnc!gatech!uflorida!reef.cis.ufl.edu!jdb From: jdb@reef.cis.ufl.edu (Brian K. W. Hook) Newsgroups: comp.std.c Subject: free() Message-ID: <25898@uflorida.cis.ufl.EDU> Date: 13 Dec 90 14:04:38 GMT Sender: news@uflorida.cis.ufl.EDU Distribution: usa Organization: UF CIS Dept. Lines: 23