what is mallloc()?how it works?

Answer Posted / raghavan

Every process has a address boundary. When a process does a malloc, memory is allocated from this boundary location and the process address boundary is moved to the new end. In linux, there is a function sbrk() that allows to change the process address boundary. sbrk(0) will return the current process address boundary and sbrk(n) will move the process boundary by n bytes.
malloc internally uses this feature to allocate memory for the requesting process.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How can you restore a redirected standard stream?

700


What is #define used for in c?

715


Who developed c language?

732


What are the characteristics of arrays in c?

699


What is the difference between new and malloc functions?

663






In which header file is the null macro defined?

977


What is hashing in c?

740


What are shell structures used for?

694


Explain what standard functions are available to manipulate strings?

716


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

737


How can I remove the trailing spaces from a string?

697


What is pre-emptive data structure and explain it with example?

3322


What are the application of c?

741


Write a program to reverse a given number in c?

682


what will be maximum number of comparisons when number of elements are given?

1528