[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Why new[] adds 4 bytes to the returned address
From: |
Ulrich Eckhardt |
Subject: |
Re: Why new[] adds 4 bytes to the returned address |
Date: |
Wed, 28 Feb 2007 07:47:19 +0100 |
User-agent: |
KNode/0.10.4 |
JeanDean wrote:
> MyClass *obj = new MyClass[3];
>
> Even though address returned by new [] is 0x00365f50,
> but obj gets automatically updated by 0x00365f54.
> Why and who adds these addtional 4 bytes to the address?
Firstly, it's not an error. Secondly, new/delete need space for their own
bookkeeping data, how else would 'delete [] obj' know how many objects to
destroy before before releasing the memory?
Uli
--
http://gcc.gnu.org/faq.html
http://parashift.com/c++-faq-lite/