Re: malloc realloc and pointers



On 29 Nov, 21:44, Peter Nilsson <ai...@xxxxxxxxxxx> wrote:
ravi <nos...@xxxxxxxxxxxxxx> wrote:

I m relatively new to C.

Then why ask questions on how it's implemented? You're
trying to run before you can crawl.

in theory this is the right answer but some people need
a concrete implementation to hang their thoughts on.

E1: "but you don't need to know the dtails of how that works!"
E2: "yes I do!"
E1: "you wouldn't expect to know the dtails of how the compiler
worked would you?"
E2: "well yes I would actually"


"I understood once I realised it's all shift registers!"
an explanation of the functioning of a digital switch,
that I felt lacked detail.



I have few queries related to malloc():

1. When we perform malloc(), the memory allocated
dynamically comes from the heap area of the process in
concern.

If you say so. The language standard does not specify how
malloc is implemented, merely how it must operate.

again, an outline sketch of an implementation can help.


Well, we then say that the heap has shrinked. my query
is: Is it that the heap physically does not shrink but
the perticular nodes are marked 'ALLOCATED' and for
subsequent calls to malloc() the memory manager
remembers them and does not reference them?

typically, yes (actually pretty well certainly, yes!)

<snip>

--
Nick Keighley
.