A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-dev/2002-November/030340.html below:

PyMem_MALLOC (was [Python-Dev] Snake farm)

PyMem_MALLOC (was [Python-Dev] Snake farm) PyMem_MALLOC (was [Python-Dev] Snake farm)Tim Peters tim.one@comcast.net
Fri, 22 Nov 2002 12:45:49 -0500
[Marc Recht]
> What about changing
> PyMem_MALLOC malloc
> to
> #define PyMem_MALLOC(n)     n ? malloc(n) : NULL

No, but expanding to malloc(n || 1) or malloc(n ? n : 1) would be 
fine.  Code in Python uses a NULL return as an indication that a memory 
operation failed, so returning NULL is never appropriate for a 
PyMem_Malloc(0) call -- the Python API guarantees that its memory 
functions return NULL to mean out-of-memory, and that 0 is an OK 
argument.

The configuration cruft should go away here.  It's proven itself too 
brittle too many times.  That is, we should pretend that all platforms 
are insane, and never pass 0 to any platform's malloc or realloc.




RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4