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

What is an arrays?

815


What is the sizeof () a pointer?

716


Write a program to print fibonacci series using recursion?

806


Tell me what is null pointer in c?

761


What are the advantages of using new operator as compared to the function malloc ()?

1026


I need a sort of an approximate strcmp routine?

817


How can I remove the leading spaces from a string?

820


regarding pointers concept

1789


Is printf a keyword?

949


Why we write conio h in c?

745


Explain the array representation of a binary tree in C.

929


What does dm mean sexually?

1020


Can static variables be declared in a header file?

801


What is a file descriptor in c?

782


Why use int main instead of void main?

823