or*****@gmail.com writes:
I have a doubt, when I free an alloced memory, how does the compiler
know how many bytes I have alloced forward the pointer.
eg:
int *coiso;
coiso=(int *)malloc(sizeof(int)*10);
free(coiso);
How the compiler know that it has to free from coiso to
coiso+(sizeof(int)*10)?
This is question 7.26 in the comp.lang.c FAQ,
<http://www.c-faq.com/malloc/freesize.html>.
See also questions 7.7 and 7.7b. While you're at it, you might read
all of section 7, and the rest of the FAQ as well. It's a very good
resource.
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.