In C, for example, the heap is managed by malloc()
, free()
, and friends. The heap manager generally works by keeping a list of free blocks in the heap with a linked list . Each free block of memory in the heap can contain a header with information about how much free memory it contains and a pointer to the next free block of memory...this all makes sense in terms of the linked-list implementation of a heap manager.
My question is, the linked list data structure requires a head
pointer, pointing to the first free memory block in the heap. In the context of glibc, for example, Where is the this pointer stored? Is it in the heap or stack? Its persistence suggest that it would be in the heap, but I don't see it explicitly mentioned anywhere.