[SDL] CodeWarrior, MacOS, C++ Object Destruction Problem

Daryl Lonnon dlonnon at frii.com
Wed Jul 23 14:28:01 PDT 2003


> Dunno if anyone else has run into this, but I'm using some C++ code in my 
> SDL app, and am running into trouble.
> 
> My C++ code is happy by itself, but once I go ahead and link with the 
> SDLmain library, things go bad.  In particular, when an object is 
> destructed, I get a crash.  Judging by where the debugger gets to, it 
> looks like there is some problem related to memory management.
> 
> I'm using CodeWarrior 8 on MacOS 9.2.2, for what it's worth.
> 
> Anyone else run into anything like this before?
>
> I'm going to try building on my Linux box and see how things go there....
> 
> -Roy

Similiar, but not with SDL and not on MacOS (I was on Solaris).

Things that are allocated with malloc(), should not be destructed
with delete.  Things that are allocated with new, should not be
destructed with free().  You need to keep this in mind when
using C libraries with C++.

To be specific, new and malloc do not allocate memory in the same
"area" of the process.  So they need to be free'd/deleted with the
appropriate calls or else the process can get confused and can core
(usually while doing a subsequent malloc/new).

That MIGHT be it (and it should be worth seeing if you are doing
that anywhere),

DarylL




More information about the SDL mailing list