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/2009-September/091578.html below:

[Python-Dev] PyMem_Malloc() vs PyObject_Malloc()

[Python-Dev] PyMem_Malloc() vs PyObject_Malloc() [Python-Dev] PyMem_Malloc() vs PyObject_Malloc()Kristján Valur Jónsson kristjan at ccpgames.com
Fri Sep 4 11:19:09 CEST 2009
I noticed something (in 2.5) yesterday, which may be a feature, but is more likely a bug.
In tokenizer.c, tok->encoding is allocated using PyMem_MALLOC().
However, this then gets handed to a node->r_str in parsetok.c, and then released in node.c using PyObject_Free().

Now, by coincidence, PyObject_Free() will default to free() for objects that it doesn't recognize, so this works.  But is this documented behavior?  The reason I ran into this was that I had redirect the PyMem_* API to a different allocator, but left the PyObject_* one alone.

My feeling Is that these two APIs shouldn't be interchangeable.  Especially since you can't hand a PyObject_Malloc'd object to PyMem_Free() so the inverse shouldn't be expected to work.

Any thoughts?

Kristján
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20090904/fdb0a03a/attachment.htm>
More information about the Python-Dev mailing list

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