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


On 12 March 2013 06:02, Tim Schumacher wrote:
> Hi All,
>
> I am using debian linux with gcc 4.7.2.
>
> I am curious and want to educate myself about the particular implementations
> of the operators new, new[], delete and delete[].
>
> 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.  I have the source for gcc-4.7.2 and I looked through it, but it was
> not obvious where to start.  I guess I was expecting to see some sort of
> metadata structure placed in the heap right before the returned pointer but
> I didn't see anything like that, or at least it was not obvious to me if I
> was looking at it.
>
> Does anyone know which source files contain the magic?  Or better yet, can
> anyone point me to a design doc that describes the overall strategy?

See libstdc++-v3/libsupc++/new_*.cc and
libstdc++-v3/libsupc++/del_*.cc for the actual (de)allocation
operators.

G++ follows the cross-vendor C++ ABI which describes the cookies used
by new[] at http://mentorembedded.github.com/cxx-abi/abi.html#array-cookies
The code for doing that is somewhere in the C++ front-end, gcc/cp/*.c


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