I'm guessing you want to learn and see how the memory is allocated. I would ignore the Undefined Behaviour answers. They are right (of course) when you talk about portability and such, but that is not your question. I think it is a really good idea to try and figure out how the allocation is done.
First I would encourage you to start looking at the malloc implementation for your platform. If that code is not available, you are out of luck and the only think you can do is google for clues how the allocation is done.
If you run linux, you can look at the malloc implementation of glibc or uclibc. Here a link to the uclibc implementation:
http://git.uclibc.org/uClibc/tree/libc/stdlib/malloc/malloc.c
The code has lot of comments, but can be overwhelming.
For your question, look at http://git.uclibc.org/uClibc/tree/libc/stdlib/malloc/malloc.h on line 104.
which is the part you are talking about. You see the layout depends on MALLOC_HEADER_SIZE which can be different for different systems. By reading the code you can learn which types to use, and on which offset the memory size is stored (in this specific implementation)
Of course, above is just an example implementation from uclibc to get you started...
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…