Index: Objects/unicodeobject.c =================================================================== --- Objects/unicodeobject.c (revision 61436) +++ Objects/unicodeobject.c (working copy) @@ -261,7 +261,7 @@ it contains). */ oldstr = unicode->str; - PyMem_RESIZE(unicode->str, Py_UNICODE, length + 1); + unicode->str = PyObject_REALLOC(unicode->str, sizeof(Py_UNICODE) * (length + 1)); if (!unicode->str) { unicode->str = (Py_UNICODE *)oldstr; PyErr_NoMemory(); @@ -310,12 +310,12 @@ never downsize it. */ if ((unicode->length < length) && unicode_resize(unicode, length) < 0) { - PyMem_DEL(unicode->str); + PyObject_DEL(unicode->str); goto onError; } } else { - unicode->str = PyMem_NEW(Py_UNICODE, length + 1); + unicode->str = (Py_UNICODE*) PyObject_MALLOC(sizeof(Py_UNICODE) * (length + 1)); } PyObject_INIT(unicode, &PyUnicode_Type); } @@ -323,7 +323,7 @@ unicode = PyObject_New(PyUnicodeObject, &PyUnicode_Type); if (unicode == NULL) return NULL; - unicode->str = PyMem_NEW(Py_UNICODE, length + 1); + unicode->str = (Py_UNICODE*) PyObject_MALLOC(sizeof(Py_UNICODE) * (length + 1)); } if (!unicode->str) { @@ -357,7 +357,7 @@ numfree < PyUnicode_MAXFREELIST) { /* Keep-Alive optimization */ if (unicode->length >= KEEPALIVE_SIZE_LIMIT) { - PyMem_DEL(unicode->str); + PyObject_DEL(unicode->str); unicode->str = NULL; unicode->length = 0; } @@ -371,7 +371,7 @@ numfree++; } else { - PyMem_DEL(unicode->str); + PyObject_DEL(unicode->str); Py_XDECREF(unicode->defenc); Py_TYPE(unicode)->tp_free((PyObject *)unicode); } @@ -608,7 +608,7 @@ /* step 2: allocate memory for the results of * PyObject_Str()/PyObject_Repr() calls */ if (callcount) { - callresults = PyMem_Malloc(sizeof(PyObject *)*callcount); + callresults = PyObject_Malloc(sizeof(PyObject *)*callcount); if (!callresults) { PyErr_NoMemory(); return NULL; @@ -755,7 +755,7 @@ } expand: if (abuffersize > 20) { - abuffer = PyMem_Malloc(abuffersize); + abuffer = PyObject_Malloc(abuffersize); if (!abuffer) { PyErr_NoMemory(); goto fail; @@ -918,9 +918,9 @@ end: if (callresults) - PyMem_Free(callresults); + PyObject_Free(callresults); if (abuffer) - PyMem_Free(abuffer); + PyObject_Free(abuffer); _PyUnicode_Resize(&string, s - PyUnicode_AS_UNICODE(string)); return string; fail: @@ -930,10 +930,10 @@ Py_DECREF(*callresult2); ++callresult2; } - PyMem_Free(callresults); + PyObject_Free(callresults); } if (abuffer) - PyMem_Free(abuffer); + PyObject_Free(abuffer); return NULL; } @@ -7942,7 +7942,7 @@ return PyUnicode_FromUnicode(self->str + start, slicelength); } else { source_buf = PyUnicode_AS_UNICODE((PyObject*)self); - result_buf = (Py_UNICODE *)PyMem_MALLOC(slicelength* + result_buf = (Py_UNICODE *)PyObject_MALLOC(slicelength* sizeof(Py_UNICODE)); if (result_buf == NULL) @@ -7953,7 +7953,7 @@ } result = PyUnicode_FromUnicode(result_buf, slicelength); - PyMem_FREE(result_buf); + PyObject_FREE(result_buf); return result; } } else { @@ -8790,7 +8790,7 @@ Py_DECREF(tmp); return NULL; } - pnew->str = PyMem_NEW(Py_UNICODE, n+1); + pnew->str = (Py_UNICODE*) PyObject_MALLOC(sizeof(Py_UNICODE) * (n+1)); if (pnew->str == NULL) { _Py_ForgetReference((PyObject *)pnew); PyObject_Del(pnew); @@ -8906,7 +8906,7 @@ PyUnicodeObject *v = u; u = *(PyUnicodeObject **)u; if (v->str) - PyMem_DEL(v->str); + PyObject_DEL(v->str); Py_XDECREF(v->defenc); PyObject_Del(v); numfree--;