http://d.puremagic.com/issues/show_bug.cgi?id=2590



--- Comment #5 from Justin Spahr-Summers <justin.spahrsumm...@gmail.com> 
2010-04-04 18:09:04 CDT ---
(In reply to comment #4)
> > The current behavior seems reasonable, because
> > 'delete' is never invoked on the object (which is necessary for a custom
> > deallocator to be used).
> 
> I don't think it is reasonable. Why should I bother to call the deallocator
> manually while the allocator is called automatically? Think about object
> creation as a transaction consisting of two operations: allocation and
> construction. If construction fails, allocation should be automatically rolled
> back.

But the allocator is *not* called automatically, strictly speaking. 'new' is
your call to the allocator. Since you use malloc() instead of the garbage
collector, 'delete' then becomes necessary.

Under normal circumstances, an exception thrown during construction wouldn't
leak memory because the garbage collector would eventually collect it; in your
code, you took on the task of manually allocating and deallocating memory for
objects of class C. It makes sense to me that such custom allocation would
entail finer management of exceptional situations.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------

Reply via email to