[Bf-committers] Klocwork source analysis

Stephen Swaney sswaney at centurytel.net
Sun Dec 3 15:11:18 CET 2006


On Sat, Dec 02, 2006 at 07:43:04PM -0700, Joe Eagar wrote:
> 
> Why would PyObject_New fail though? I don't get it, that seems as likely 
> as MEM_callocN failing.

We check for errors not based on their likelihood but on their
possibility.

Allocation failures are usually described as out of memory errors.
This is a shorthand description for the actual conditions: you asked
for a block of memory and the system was unable to provide a
*contiguous* block of that size.

You may have 50 Meg free, but if it is fragmented into 1/2 K chunks, a
request for 1K will fail.

Another possibility is you simply requested an insanely huge amount.
>From an actual forum post:

Calloc returns nill: len=2053778024 in layerCopy_mdeformvert dw, total
10887064

Yeah. 2,053,778,024 bytes.  Whether this represents a programming
error, or simply outrageous user settings, we still don't want to
crash blender.

Good error checking is a mark of a robust application.

-- 
Stephen Swaney			
sswaney at centurytel.net



More information about the Bf-committers mailing list