Question about implementation of new/delete and new/delete in gnu gcc
Wed Mar 13 15:14:00 GMT 2013
* Tim Schumacher:
> Specifically, I was curious about what meta data is stored about the
> allocations (size/# of elements in the array case), and where that
> data is stored.
Certain types require a "cookie" which stores the length, and it is
stored just before the pointer that operator new returns. The rules
for when a cookie is needed are somewhat complex and depend on the ABI
version. The layout of the cookie field is ABI-dependent as well
(beyond mere differences in word size).
Searching for "cookie" in gcc/cp/*.c should point you into the right
operator new is expanded in-line by the compiler, so most of the
run-time library support routines Jonathan mentioned are not actually
used by GCC, but are provided for use by other compilers.
More information about the Gcc-help