[Scummvm-devel] SCI mem functions

Rafał Rzepecki divided.mind at gmail.com
Wed Feb 18 00:30:37 CET 2009


At Tuesday 17 of February 2009 19:41 Joost Peters wrote:
> Filippos Karapetis schreef:
> > Well... in that case we should either have similar wrappers for the rest
> > of the ScummVM code,
> > or perform alternate kind of testing, or no testing at all...
>
> Aye.  *Ideally* all engines/code would check the return value of
> malloc/new in all places it is used, and give "out of memory" errors,
> rather than crashing in obscure ways, like they often do now.  A generic
> wrapper could be useful, but also problematic, as was pointed out before.
>
> > Moreover, a lot of engines run relatively well in memory-constrained
> > platforms without the
> > need for such checks.
>
> Sure, many do, and a few don't.   If you look into the bugs reported for
> DS, especially in the early days, often games would simply freeze when
> out of memory.
>
> Anyway, I merely wanted to point out the fact that you can't expect
> malloc() to always succeed, in response to your statement that it should
> never fail, unless there is a leak. :)

Well, many (including myself) would argue that if malloc() fails, it _should_ 
crash and it should crash hard, given there's nothing you can really do about 
it. (So IMHO if anything we should make sure it'd always crash instead of 
freezing -- and indeed on platforms where there is nothing to crash _to_ -- 
perhaps there should be some kind of a wrapper to give the user some crash 
feedback. But that should really be platform-specific; I'm pretty much against 
clobbering core code with assumption that malloc could fail.)
-- 
- Rafał Rzepecki




More information about the Scummvm-devel mailing list