malloc()
is a library wrapper function over many levels of low-layer memory allocation call. It hides details like the size of actual memory size allocated by the memory allocator of the OS and directly returns a valid pointer (in case of success) to the application making the call. The pointer can be used safely (within the bounds) and passed to free()
after the usage is done.
The pointer returned as the return value of malloc()
need not be (and most of the time, it's not) the actual address returned by the memory allocator. OS/ memory allocator does some book-keeping under the hood to keep the track of size of allocated memory and then after some adjustments, it passes a pointer to the malloc()
which is then returned to the application calling malloc()
.
There is no standard way of getting the actual info (it was meant to be hidden from the user, because of proper reasons, IMHO), but there are platform-dependent ways of getting the info.