This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Question about implementation of new/delete and new[]/delete[] in gnu gcc


* 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
direction.

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]