PyMem_MALLOC (was [Python-Dev] Snake farm)
Fri, 22 Nov 2002 17:11:39 +0100
>> The problem seems to be in the FreeBSD malloc implementation. malloc(0)
>> returns 0x800 in all my tests. malloc(1) and up seems to work properly..
> Maybe we have to relax the configure test a bit and set
> the MALLOC_ZERO_RETURNS_NULL #define not only on NULL
> returns, but on returns < 0x1000 as well ?! (or add
> something to pyport.h along these lines specific to
I've just got an answer on the FreeBSD-current list:
Feature in malloc and bug in third-party code. C99 says:
If the size of the space requested is zero, the behavior
is implimentation defined: either a null pointer is returned,
or the behavior is as if the size were some nonzero value,
except that the returned pointer shall not be used to access
So, if it's correct, then this isn't a FreeBSD specific problem and 0x800
could possibly something else on ther systems. Even above 0x1000.
Maybe the part that wraps malloc could be changed to return NULL for
malloc(0) (without calling malloc).