lua-users home
lua-l archive

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

Worse still: regardless of runtime library implementation new and delete typically call constructors and destructors respectively. This is something that - if I'm not mistaken - malloc and free simply won't do...

So, regarding the sample code below: you could be in for a nasty surprise if you're not very careful about initializing the object array (allocated through malloc), depending on the destructors that are called later on (through the delete[]).

Then again, Nils' problem could easily be caused by a multitude of other issues...

I suggest to stay away from C++ (and several other programming languages, for that matter) if you're not really sure about what you're doing. If you're going to shoot yourself in the foot, you might as well find a more enjoyable way to do it.


On Tue, 19 Oct 2004 19:02:26 -0700, Ben Sunshine-Hill <> wrote:

Bingo. new/delete and malloc/free do NOT play well together... they
aren't interchangeable in the slightest under most runtime libraries.

On Wed, 20 Oct 2004 03:59:55 +0200, Nils Wogatzky <> wrote:
First of all thank you for your quick reply.

Do I mix malloc with delete ?

savObjects = (T**)malloc(Size * sizeof(Objects));
delete [] savObjects;

like this ?

Then I do, yes. I´m not that good in C++ =)

To your second question ("..Use of objects..") I can reply: I just use function-calls.

I´ll try to find a memory-debugging tool to fix the problem.
(After that I´ll read some C++ - Tutorials and find out why I shouldn´t use malloc and delete;-) )

Thank you

no signature is a signature.