In C programming, you can pass any kind of pointer you like as an argument to free, how does it know the size of the allocated memory to free? Whenever I pass a pointer to s
The heap manager stored the amount of memory belonging to the allocated block somewhere when you called malloc.
malloc
I never implemented one myself, but I guess the memory right in front of the allocated block might contain the meta information.