I just started reading The C Programming Language by Brian Kernighan and Dennis Ritchie, and I found this statement:
The language does not define any storage allocation facility other than static definition and the stack discipline provided by the local variables of functions; there is no heap or garbage collection.
So does this mean that it is due to the malloc()
function, which returns some memory address from heap, that C enjoys access to the Heap memory? And then must malloc
be written in some other language, most probably assembly or B?
This may be a silly doubt, but I have to clear it. Thanks.
malloc()
function or the book itself. If I were to guess which one was wrong I would guess the book. I can tell you that malloc() is written in the same language as everything else. - Security Houndmalloc()
is part of the C library, but I think what the book is saying that intrinsically, the language does not specify a necessity for heap allocation. - wklmalloc
takes its memory is unspecified, and as it turns out we all call it 'the heap'. - zneak