summaryrefslogtreecommitdiffstats
path: root/Modules/pyexpat.c
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2013-07-07 15:35:11 (GMT)
committerChristian Heimes <christian@cheimes.de>2013-07-07 15:35:11 (GMT)
commitfa535f5220592ed2bb668e2c6ddedf13a450d945 (patch)
tree0f6f525b628f559c7417cba2146c17a2bea30d88 /Modules/pyexpat.c
parent0e2d3cf2cba644f573968737e3ee4f76285d54d3 (diff)
downloadcpython-fa535f5220592ed2bb668e2c6ddedf13a450d945.zip
cpython-fa535f5220592ed2bb668e2c6ddedf13a450d945.tar.gz
cpython-fa535f5220592ed2bb668e2c6ddedf13a450d945.tar.bz2
Issue #18227: pyexpat now uses a static XML_Memory_Handling_Suite. cElementTree uses the same approach since at least Python 2.6
Diffstat (limited to 'Modules/pyexpat.c')
-rw-r--r--Modules/pyexpat.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c
index 1568002..f04620f 100644
--- a/Modules/pyexpat.c
+++ b/Modules/pyexpat.c
@@ -10,6 +10,9 @@
#define FIX_TRACE
+static XML_Memory_Handling_Suite ExpatMemoryHandler = {
+ PyObject_Malloc, PyObject_Realloc, PyObject_Free};
+
enum HandlerTypes {
StartElement,
EndElement,
@@ -1177,12 +1180,9 @@ newxmlparseobject(char *encoding, char *namespace_separator, PyObject *intern)
self->in_callback = 0;
self->ns_prefixes = 0;
self->handlers = NULL;
- if (namespace_separator != NULL) {
- self->itself = XML_ParserCreateNS(encoding, *namespace_separator);
- }
- else {
- self->itself = XML_ParserCreate(encoding);
- }
+ /* namespace_separator is either NULL or contains one char + \0 */
+ self->itself = XML_ParserCreate_MM(encoding, &ExpatMemoryHandler,
+ namespace_separator);
#if ((XML_MAJOR_VERSION >= 2) && (XML_MINOR_VERSION >= 1)) || defined(XML_HAS_SET_HASH_SALT)
/* This feature was added upstream in libexpat 2.1.0. Our expat copy
* has a backport of this feature where we also define XML_HAS_SET_HASH_SALT