https://github.com/python/cpython/commit/53d921ed96e1c57b2e42f984d3a5ca8347fedb81
commit: 53d921ed96e1c57b2e42f984d3a5ca8347fedb81
branch: main
author: Erlend E. Aasland <[email protected]>
committer: erlend-aasland <[email protected]>
date: 2024-01-29T21:48:49+01:00
summary:
gh-114569: Use PyMem_* APIs for non-PyObjects in unicodeobject.c (#114690)
files:
M Objects/unicodeobject.c
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 4b03cc3f4da5fa..b236ddba9cdc69 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -996,7 +996,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length)
new_size = (struct_size + (length + 1) * char_size);
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
- PyObject_Free(_PyUnicode_UTF8(unicode));
+ PyMem_Free(_PyUnicode_UTF8(unicode));
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
@@ -1049,7 +1049,7 @@ resize_inplace(PyObject *unicode, Py_ssize_t length)
if (!share_utf8 && _PyUnicode_HAS_UTF8_MEMORY(unicode))
{
- PyObject_Free(_PyUnicode_UTF8(unicode));
+ PyMem_Free(_PyUnicode_UTF8(unicode));
_PyUnicode_UTF8(unicode) = NULL;
_PyUnicode_UTF8_LENGTH(unicode) = 0;
}
@@ -1590,10 +1590,10 @@ unicode_dealloc(PyObject *unicode)
return;
}
if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) {
- PyObject_Free(_PyUnicode_UTF8(unicode));
+ PyMem_Free(_PyUnicode_UTF8(unicode));
}
if (!PyUnicode_IS_COMPACT(unicode) && _PyUnicode_DATA_ANY(unicode)) {
- PyObject_Free(_PyUnicode_DATA_ANY(unicode));
+ PyMem_Free(_PyUnicode_DATA_ANY(unicode));
}
Py_TYPE(unicode)->tp_free(unicode);
@@ -5203,7 +5203,7 @@ unicode_fill_utf8(PyObject *unicode)
PyBytes_AS_STRING(writer.buffer);
Py_ssize_t len = end - start;
- char *cache = PyObject_Malloc(len + 1);
+ char *cache = PyMem_Malloc(len + 1);
if (cache == NULL) {
_PyBytesWriter_Dealloc(&writer);
PyErr_NoMemory();
@@ -14674,7 +14674,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject
*unicode)
PyErr_NoMemory();
goto onError;
}
- data = PyObject_Malloc((length + 1) * char_size);
+ data = PyMem_Malloc((length + 1) * char_size);
if (data == NULL) {
PyErr_NoMemory();
goto onError;
_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]