RE: operator new[] and operator delete[]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> I've noticed if I do:
>
> Object *o = new Object[100];
> 
> It calls new[] but if I do
> 
> delete o;
> 
> later it calls delete and therefore isn't symmetrical.  How can I get
> delete[] called?

You need to call the array delete using the following syntax :

delete [] o;

If you simply "delete o;", as in your example, you are only deleting the
first object in the array (and leaving 99 "orphaned" objects in memory).

  - Mike


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux