On Sun, Sep 29, 2002 at 02:54:19PM +0200, Russell Coker wrote: > 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. [...] > 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. i think that is what is happening in this code snippet. the orbit (a C library) call is allocating something, thus free is necessary to unallocate it. -- gram
Attachment:
pgpTETrcTMBGm.pgp
Description: PGP signature