cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
General C++ Programming
a question about "free"
a question about "free"
Feb 11, 2012 at 1:51am UTC
tao zhang
(3)
int* i = malloc(4*sizeof(int));
free(i)
problem:
how free function know to free 4*sizeof(int) bytes?
Feb 11, 2012 at 1:54am UTC
Athar
(4466)
That depends on the implementation, but usually the memory management will store the allocated size somewhere (for example, directly before the returned address).
Last edited on
Feb 11, 2012 at 2:03am UTC
Topic archived. No new replies allowed.