free()
    Brian K. W. Hook 
    jdb at reef.cis.ufl.edu
       
    Fri Dec 14 01:04:38 AEST 1990
    
    
  
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.
    
    
More information about the Comp.std.c
mailing list