summaryrefslogtreecommitdiffstats
path: root/Objects/unicodeobject.c
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2000-05-03 23:44:39 (GMT)
committerGuido van Rossum <guido@python.org>2000-05-03 23:44:39 (GMT)
commitb18618dab7b6b85bb05b084693706e59211fa180 (patch)
tree785d51f6677da8366be2ad4b4296a62f53161276 /Objects/unicodeobject.c
parent2808b744e8d94459f189e1d89c97072d6a1f53b6 (diff)
downloadcpython-b18618dab7b6b85bb05b084693706e59211fa180.zip
cpython-b18618dab7b6b85bb05b084693706e59211fa180.tar.gz
cpython-b18618dab7b6b85bb05b084693706e59211fa180.tar.bz2
Vladimir Marangozov's long-awaited malloc restructuring.
For more comments, read the patches@python.org archives. For documentation read the comments in mymalloc.h and objimpl.h. (This is not exactly what Vladimir posted to the patches list; I've made a few changes, and Vladimir sent me a fix in private email for a problem that only occurs in debug mode. I'm also holding back on his change to main.c, which seems unnecessary to me.)
Diffstat (limited to 'Objects/unicodeobject.c')
-rw-r--r--Objects/unicodeobject.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 7a68dd4..601b987 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -200,14 +200,13 @@ PyUnicodeObject *_PyUnicode_New(int length)
unicode = unicode_freelist;
unicode_freelist = *(PyUnicodeObject **)unicode_freelist;
unicode_freelist_size--;
- unicode->ob_type = &PyUnicode_Type;
- _Py_NewReference((PyObject *)unicode);
+ PyObject_INIT(unicode, &PyUnicode_Type);
if (unicode->str) {
/* Keep-Alive optimization: we only upsize the buffer,
never downsize it. */
if ((unicode->length < length) &&
_PyUnicode_Resize(unicode, length)) {
- free(unicode->str);
+ PyMem_DEL(unicode->str);
goto onError;
}
}
@@ -233,7 +232,7 @@ PyUnicodeObject *_PyUnicode_New(int length)
onError:
_Py_ForgetReference((PyObject *)unicode);
- PyMem_DEL(unicode);
+ PyObject_DEL(unicode);
return NULL;
}
@@ -243,7 +242,7 @@ void _PyUnicode_Free(register PyUnicodeObject *unicode)
if (unicode_freelist_size < MAX_UNICODE_FREELIST_SIZE) {
/* Keep-Alive optimization */
if (unicode->length >= KEEPALIVE_SIZE_LIMIT) {
- free(unicode->str);
+ PyMem_DEL(unicode->str);
unicode->str = NULL;
unicode->length = 0;
}
@@ -257,9 +256,9 @@ void _PyUnicode_Free(register PyUnicodeObject *unicode)
unicode_freelist_size++;
}
else {
- free(unicode->str);
+ PyMem_DEL(unicode->str);
Py_XDECREF(unicode->utf8str);
- PyMem_DEL(unicode);
+ PyObject_DEL(unicode);
}
}
@@ -4662,9 +4661,9 @@ _PyUnicode_Fini()
PyUnicodeObject *v = u;
u = *(PyUnicodeObject **)u;
if (v->str)
- free(v->str);
+ PyMem_DEL(v->str);
Py_XDECREF(v->utf8str);
- free(v);
+ PyObject_DEL(v);
}
Py_XDECREF(unicode_empty);
}