In C (or even C ++, I believe) there is no legal way to do this. Yes, it somehow freeknows how much malloced was, but it does it so that it is not visible or accessible to the programmer. For you, a programmer, he could do it by magic!
, malloc , . , ( , malloc (, )) -.