How does free() know how many bytes to free?

Answer Posted / vrushali

Whenever we call malloc() for allocating memory. The value
of the starting address is stored in a virtual memory tables.
So whenever free() is called then using the starting memory
location free () will have an entry of the bytes allocated
and to be freed. It can do it using this entry then entry is
deleted also.
This is pure OS concept.

Please reply here if you are not able to understand my answer.

Is This Answer Correct ?    4 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When should I declare a function?

616


What is spaghetti programming?

664


What's the difference between constant char *p and char * constant p?

649


Is fortran still used in 2018?

585


What is the use of extern in c?

639






Is it better to use a pointer to navigate an array of values, or is it better to use a subscripted array name?

646


Explain the advantages and disadvantages of macros.

616


Write a program on swapping (100, 50)

634


write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.

1512


Tell me what is the purpose of 'register' keyword in c language?

611


Is it better to use malloc() or calloc()?

643


Why cant I open a file by its explicit path?

590


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

1895


How does selection sort work in c?

614


Why does everyone say not to use gets?

603