How memory function free() knows how much memory to free.

P

Panduranga Chary

Hi,

How does the memory management function 'free()' frees the memory
pointed by a pointer variable at run time. how does it know the size.
if there is way when free() can do, then why can't we do it
externally?.


Thanks
Panduranga Chary
 
M

MisterE

Hi,

How does the memory management function 'free()' frees the memory
pointed by a pointer variable at run time. how does it know the size.
if there is way when free() can do, then why can't we do it
externally?.

When you malloc memory, the size of the allocated block is stored somewhere.
What do you mean by externally?
 
K

Keith Thompson

Panduranga Chary said:
How does the memory management function 'free()' frees the memory
pointed by a pointer variable at run time. how does it know the size.
if there is way when free() can do, then why can't we do it
externally?.

The comp.lang.c FAQ is at <http://www.c-faq.com/>.
You've just asked question 7.26.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top