H
Hongzheng Wang
Hi, everyone
I have a problem about malloc/free function.
Does malloc add size information to program? And, when free function is
called, how this function get the size information?
That is, if I request a memory block of size 10, where the size
information 10 is stored?
To be clear, I have such codes below:
int *p = (int *) malloc(10*sizeof(int));
/* ...... */
p[5] = '\0';
/* ...... */
free p;
Will these codes cause memory leak?
I'm not clear about this problem.
Thank you for your help. ^_^
I have a problem about malloc/free function.
Does malloc add size information to program? And, when free function is
called, how this function get the size information?
That is, if I request a memory block of size 10, where the size
information 10 is stored?
To be clear, I have such codes below:
int *p = (int *) malloc(10*sizeof(int));
/* ...... */
p[5] = '\0';
/* ...... */
free p;
Will these codes cause memory leak?
I'm not clear about this problem.
Thank you for your help. ^_^