[Scummvm-devel] CVS: "added extra flag to mixer so we don't use free() on new'd pointers"
kpharris at networld.com
Sun Oct 26 11:59:05 CET 2003
> > It is very backwards to oppose the use of C++ in a C++ program.
> > Joost made a very simple solution to a big problem in ScummVM. Using
> > malloc/free
> > in a C++ program is just plain wrong, unless your development language
> > actually
> > is "C with classes" instead of C++.
Part of the beauty of C++ is that they allow you to do things in any number
of ways as you see fit. If you don't like new/delete, you can use
malloc/free, or even some form of garbage collection.
> That's plain nonsense in my eyes. "new" is primarily meant to allocate
> objects (because it implicitly invokes the constructor for these
> objects, just like delete invokes the destructor). For data buffers,
Yes the constructor is called on everything that is allocated with new, but
the constructor for internal data types does nothing (doesn't initialize the
values), and shouldn't even cause overhead. The overhead caused by any
callback functions (or functors) should be fairly small, and would only
result in a little more being added to the interface.
> there is absolutely no reason not to use malloc/free, not even from a
> theoretical point of view.
Actually, from a standardized memory allocation view, there is a reason to
have all memory allocations and deallocations done in the same way. It
reduces the chances of someone making a horrible mistake. However, if there
is sufficient doccumentation about the type of memory allocation a specific
interface requires, then it should be alright to go ahead and use whatever
method you like.
> > The way of perfection would be to change all uses of malloc/free in
> > ScummVM to
> > new/delete,
> NO! That's just silly nonsense. I am not commenting on the rest of the
> mail, but my opinion on it is exactly the same.
I don't believe that there is a perfect program, nor is there a perfect way
of doing anything. Personally, I prefer the use of new/delete to
malloc/free, and it can [sometimes] lower the amount of work to be done
if/when the data types need to be changed (which probably won't happen in
More information about the Scummvm-devel