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

Re: memory debugging and C++ (program keeps crashing)



On Sun, Sep 29, 2002 at 03:51:48PM -0700, Sean 'Shaleh' Perry wrote:
> >     Marc> Actually, with GCC it doesn't matter which call you use.
> >     Marc> New uses the malloc function.  You can free () or delete
> >     Marc> memory allocated with malloc () or new.  New and delete are
> >     Marc> 'syntactic sugar' for malloc and free.
> 
> indeed.  Using free() on a piece of memory allocated by new is rather 
> dangerous, you have no idea what the C++ library is doing behind the scenes.  
> Plus as Shyamal points out, none of the destructors that should be called 
> would be.  Just because malloc() happens to be the deep, deep implementation 
> does not mean there is not useful and important code inbetween.

I don't think Marc meant to condone this, just to say that it's probably not
what's causing the crash.

-- 
Glenn Maynard



Reply to: