[Scummvm-devel] "free(0)" is valid C, and so is "delete 0;"

John Willis John.Willis at Distant-Earth.Co.Uk
Sun Aug 1 16:06:08 CEST 2004


>If I learned one thing, it's "Never say never". But I can say that none 
>of our target platforms has such a hideous buggy standard library --
>else our existing code wouldn't work (as it already relies on this).

*cough*, GP32 port, *cough* ;-)

That said it's largely academic as the CVS code is long past working anyway
(I REALLY must submit a patch as soon as my code works again).

GCC when implemented on the GP32 (using its SDK Malloc/Free wrappers)
actually needs VERY evil hacks that effectively map New and Delete to
wrapped Malloc and Free (and none of those wrappers are completely
predicable when chucked things like (0)).

e.g.

void* operator new[]( size_t size ) throw(std::bad_alloc) {
	return ::gm_malloc(size);
}

My current code wraps the SDK Malloc and Free to fix the implementation but
unfortunately I broke the port against CVS recently and I have not worked
out what is wrong yet ;-) (I think I broke the String class, no idea how).

For what it's worth I would make the point this it might make sense to
standardise on a Malloc/Free or New/Delete strategy (recent commits seem to
hint at some mixing) and 'maybe' mention the (0) assumption in the code
docs.

Still, the point of this post was just to remind people that some things are
far from sensible and standard.

Regards

	John







More information about the Scummvm-devel mailing list