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

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



On Sun, 29 Sep 2002 14:40, Jon Dowland wrote:
> On Sun, Sep 29, 2002 at 04:25:41PM +1000, Brian May wrote:
> > List *list = [...orbit call...]
> > for (each item in list) {
> >   Value &value = list[x];
> >   save(&value);
> > }
> > free(list)
>
> Forgive me if I'm missing the point, but shouldn't you be using
> new/delete if you are writing in C++? Since they are language
> constructs rather than functions, I imagine it would be much
> harder for a memory debugger to keep track of however.

A memory debugger written for C++ can catch the default use of new/delete.  
However if you over-ride them for your class then you can confuse the 
debugger (but usually you don't do that).

Also if you allocate memory that some C code will free or if you want to free 
code that was (or might have been) allocated by C code then you need to use 
malloc/free in your C++ program.

-- 
http://www.coker.com.au/selinux/   My NSA Security Enhanced Linux packages
http://www.coker.com.au/bonnie++/  Bonnie++ hard drive benchmark
http://www.coker.com.au/postal/    Postal SMTP/POP benchmark
http://www.coker.com.au/~russell/  My home page



Reply to: