[Python-Dev] Problem with the memory docs (original) (raw)
Martin v. Loewis martin@v.loewis.de
05 Apr 2002 09:39:31 +0200
- Previous message: [Python-Dev] Problem with the memory docs
- Next message: [Python-Dev] Problem with the memory docs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Tim Peters <tim.one@comcast.net> writes:
[martin@v.loewis.de] > That, OTOH, is not what Guido wants it to be. Guido wants PyMalloc to > return 0 only in case of failure; allocating 0 bytes should > "normally" succeed. I still cannot see what problems you have with > this requirement.
I'm not following this at all. Calling malloc(1) does exactly what Guido wants. "malloc(1)" isn't a broken Unix manpage reference, if that's how you're reading it; it means call malloc with an argument of 1.
I think I'm now getting to the root of your confusion. Calling malloc(1) is not what Guido wants. Instead, he wants that py_malloc(0) returns a non-null pointer "normally".
Now, there are some C libraries which normally return a NULL pointer for malloc(0); as you point out, C gives them the freedom to do so. To work-around this under-specification, one can call malloc(1) - standards mandate that this does attempt to allocate something. It may be possible to find different work-arounds, but this is the most straight-forward one.
Regards, Martin
- Previous message: [Python-Dev] Problem with the memory docs
- Next message: [Python-Dev] Problem with the memory docs
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]