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 auto keyword in c?

792


Tell me can the size of an array be declared at runtime?

601


How can I trap or ignore keyboard interrupts like control-c?

620


What is variable in c example?

596


Is c weakly typed?

581






diff between exptected result and requirement?

1597


Explain the advantages of using macro in c language?

584


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1523


Here is a neat trick for checking whether two strings are equal

567


What is the hardest programming language?

673


Differentiate between functions getch() and getche().

627


The process of repeatedly running a set of computer instructions until some condition is specifed a) condition b) sequential condition c) global d) iteration

636


Why is c still so popular?

619


Can you add pointers together? Why would you?

650


Which is best book for data structures in c?

601