> The docs for PyMem_Malloc say: > > Requesting zero bytes returns a non-NULL pointer. > > I can't guarantee this without insane effort, and our code has never > guaranteed this. If pymalloc or the platform allocator can't even allocate > one byte in this case, nothing can be done to guarantee it except to return > "an address" fabricated out of thin air, and guaranteed not to match any > legitimate address. Then realloc and free would have to special-case the > snot out of those fabricated addresses to avoid going insane. Note that C > does not guarantee malloc(0) will return a non-NULL pointer, even on > platforms where malloc(0) *tries* to return a non-NULL pointer. It doesn't > have a choice about this: since all non-NULL addresses returned by a > conforming C malloc() have to be pairwise distinct so long as none are > free()'ed, you can provoke any C implementation into returning NULL for > malloc(0) just by calling malloc(0) often enough without doing any free()s. > > I vote to change the docs. If you vote for something else, you implement it > <wink>. The whole post is a joke, right? You just mean that it can still return NULL when it runs out of memory, so the docs should say that? --Guido van Rossum (home page: http://www.python.org/~guido/)
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