diff options
author | Victor Stinner <vstinner@python.org> | 2020-12-01 09:37:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-01 09:37:39 (GMT) |
commit | 32bd68c839adb7b42af12366ab0892303115d1d1 (patch) | |
tree | 205358a43a500fedb97ad0e370fbc998b42b3ae7 /Objects | |
parent | 00d7abd7ef588fc4ff0571c8579ab4aba8ada1c0 (diff) | |
download | cpython-32bd68c839adb7b42af12366ab0892303115d1d1.zip cpython-32bd68c839adb7b42af12366ab0892303115d1d1.tar.gz cpython-32bd68c839adb7b42af12366ab0892303115d1d1.tar.bz2 |
bpo-42519: Replace PyObject_MALLOC() with PyObject_Malloc() (GH-23587)
No longer use deprecated aliases to functions:
* Replace PyObject_MALLOC() with PyObject_Malloc()
* Replace PyObject_REALLOC() with PyObject_Realloc()
* Replace PyObject_FREE() with PyObject_Free()
* Replace PyObject_Del() with PyObject_Free()
* Replace PyObject_DEL() with PyObject_Free()
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/bytesobject.c | 8 | ||||
-rw-r--r-- | Objects/capsule.c | 2 | ||||
-rw-r--r-- | Objects/codeobject.c | 2 | ||||
-rw-r--r-- | Objects/complexobject.c | 2 | ||||
-rw-r--r-- | Objects/dictobject.c | 8 | ||||
-rw-r--r-- | Objects/floatobject.c | 4 | ||||
-rw-r--r-- | Objects/longobject.c | 2 | ||||
-rw-r--r-- | Objects/object.c | 4 | ||||
-rw-r--r-- | Objects/odictobject.c | 2 | ||||
-rw-r--r-- | Objects/rangeobject.c | 4 | ||||
-rw-r--r-- | Objects/stringlib/unicode_format.h | 4 | ||||
-rw-r--r-- | Objects/typeobject.c | 6 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 42 |
13 files changed, 45 insertions, 45 deletions
diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index bb84409..13216b9 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -198,7 +198,7 @@ PyBytes_FromString(const char *str) } /* Inline PyObject_NewVar */ - op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + size); + op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + size); if (op == NULL) { return PyErr_NoMemory(); } @@ -1475,7 +1475,7 @@ bytes_repeat(PyBytesObject *a, Py_ssize_t n) "repeated bytes are too long"); return NULL; } - op = (PyBytesObject *)PyObject_MALLOC(PyBytesObject_SIZE + nbytes); + op = (PyBytesObject *)PyObject_Malloc(PyBytesObject_SIZE + nbytes); if (op == NULL) { return PyErr_NoMemory(); } @@ -3054,9 +3054,9 @@ _PyBytes_Resize(PyObject **pv, Py_ssize_t newsize) _Py_ForgetReference(v); #endif *pv = (PyObject *) - PyObject_REALLOC(v, PyBytesObject_SIZE + newsize); + PyObject_Realloc(v, PyBytesObject_SIZE + newsize); if (*pv == NULL) { - PyObject_Del(v); + PyObject_Free(v); PyErr_NoMemory(); return -1; } diff --git a/Objects/capsule.c b/Objects/capsule.c index a2ff642..800a6c4 100644 --- a/Objects/capsule.c +++ b/Objects/capsule.c @@ -260,7 +260,7 @@ capsule_dealloc(PyObject *o) if (capsule->destructor) { capsule->destructor(o); } - PyObject_DEL(o); + PyObject_Free(o); } diff --git a/Objects/codeobject.c b/Objects/codeobject.c index 0257295..0b0b8f9 100644 --- a/Objects/codeobject.c +++ b/Objects/codeobject.c @@ -669,7 +669,7 @@ code_dealloc(PyCodeObject *co) PyObject_GC_Del(co->co_zombieframe); if (co->co_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject*)co); - PyObject_DEL(co); + PyObject_Free(co); } static PyObject * diff --git a/Objects/complexobject.c b/Objects/complexobject.c index a481d9a..a65ebdf 100644 --- a/Objects/complexobject.c +++ b/Objects/complexobject.c @@ -233,7 +233,7 @@ PyObject * PyComplex_FromCComplex(Py_complex cval) { /* Inline PyObject_New */ - PyComplexObject *op = PyObject_MALLOC(sizeof(PyComplexObject)); + PyComplexObject *op = PyObject_Malloc(sizeof(PyComplexObject)); if (op == NULL) { return PyErr_NoMemory(); } diff --git a/Objects/dictobject.c b/Objects/dictobject.c index ee1a9d1..7a37313 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -269,7 +269,7 @@ _PyDict_ClearFreeList(PyThreadState *tstate) PyObject_GC_Del(op); } while (state->keys_numfree) { - PyObject_FREE(state->keys_free_list[--state->keys_numfree]); + PyObject_Free(state->keys_free_list[--state->keys_numfree]); } } @@ -597,7 +597,7 @@ new_keys_object(Py_ssize_t size) } else { - dk = PyObject_MALLOC(sizeof(PyDictKeysObject) + dk = PyObject_Malloc(sizeof(PyDictKeysObject) + es * size + sizeof(PyDictKeyEntry) * usable); if (dk == NULL) { @@ -636,7 +636,7 @@ free_keys_object(PyDictKeysObject *keys) state->keys_free_list[state->keys_numfree++] = keys; return; } - PyObject_FREE(keys); + PyObject_Free(keys); } #define new_values(size) PyMem_NEW(PyObject *, size) @@ -1303,7 +1303,7 @@ dictresize(PyDictObject *mp, Py_ssize_t newsize) state->keys_free_list[state->keys_numfree++] = oldkeys; } else { - PyObject_FREE(oldkeys); + PyObject_Free(oldkeys); } } diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 1550b2e..34fb57a 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -237,7 +237,7 @@ float_dealloc(PyFloatObject *op) assert(state->numfree != -1); #endif if (state->numfree >= PyFloat_MAXFREELIST) { - PyObject_FREE(op); + PyObject_Free(op); return; } state->numfree++; @@ -2032,7 +2032,7 @@ _PyFloat_ClearFreeList(PyThreadState *tstate) PyFloatObject *f = state->free_list; while (f != NULL) { PyFloatObject *next = (PyFloatObject*) Py_TYPE(f); - PyObject_FREE(f); + PyObject_Free(f); f = next; } state->free_list = NULL; diff --git a/Objects/longobject.c b/Objects/longobject.c index e0d6410..240e92a 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -131,7 +131,7 @@ _PyLong_New(Py_ssize_t size) "too many digits in integer"); return NULL; } - result = PyObject_MALLOC(offsetof(PyLongObject, ob_digit) + + result = PyObject_Malloc(offsetof(PyLongObject, ob_digit) + size*sizeof(digit)); if (!result) { PyErr_NoMemory(); diff --git a/Objects/object.c b/Objects/object.c index 2e8717f..0a8621b 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -161,7 +161,7 @@ PyObject_InitVar(PyVarObject *op, PyTypeObject *tp, Py_ssize_t size) PyObject * _PyObject_New(PyTypeObject *tp) { - PyObject *op = (PyObject *) PyObject_MALLOC(_PyObject_SIZE(tp)); + PyObject *op = (PyObject *) PyObject_Malloc(_PyObject_SIZE(tp)); if (op == NULL) { return PyErr_NoMemory(); } @@ -174,7 +174,7 @@ _PyObject_NewVar(PyTypeObject *tp, Py_ssize_t nitems) { PyVarObject *op; const size_t size = _PyObject_VAR_SIZE(tp, nitems); - op = (PyVarObject *) PyObject_MALLOC(size); + op = (PyVarObject *) PyObject_Malloc(size); if (op == NULL) { return (PyVarObject *)PyErr_NoMemory(); } diff --git a/Objects/odictobject.c b/Objects/odictobject.c index 83b326b..4eb15f9 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -459,7 +459,7 @@ later: - implement a fuller MutableMapping API in C? - move the MutableMapping implementation to abstract.c? - optimize mutablemapping_update -- use PyObject_MALLOC (small object allocator) for odict nodes? +- use PyObject_Malloc (small object allocator) for odict nodes? - support subclasses better (e.g. in odict_richcompare) */ diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c index 787d113..530426c 100644 --- a/Objects/rangeobject.c +++ b/Objects/rangeobject.c @@ -171,7 +171,7 @@ range_dealloc(rangeobject *r) Py_DECREF(r->stop); Py_DECREF(r->step); Py_DECREF(r->length); - PyObject_Del(r); + PyObject_Free(r); } /* Return number of items in range (lo, hi, step) as a PyLong object, @@ -1021,7 +1021,7 @@ longrangeiter_dealloc(longrangeiterobject *r) Py_XDECREF(r->start); Py_XDECREF(r->step); Py_XDECREF(r->len); - PyObject_Del(r); + PyObject_Free(r); } static PyObject * diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h index b526ad2..7152ec6 100644 --- a/Objects/stringlib/unicode_format.h +++ b/Objects/stringlib/unicode_format.h @@ -983,7 +983,7 @@ static void formatteriter_dealloc(formatteriterobject *it) { Py_XDECREF(it->str); - PyObject_FREE(it); + PyObject_Free(it); } /* returns a tuple: @@ -1147,7 +1147,7 @@ static void fieldnameiter_dealloc(fieldnameiterobject *it) { Py_XDECREF(it->str); - PyObject_FREE(it); + PyObject_Free(it); } /* returns a tuple: diff --git a/Objects/typeobject.c b/Objects/typeobject.c index fbadd31..83bc877 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -1059,7 +1059,7 @@ PyType_GenericAlloc(PyTypeObject *type, Py_ssize_t nitems) obj = _PyObject_GC_Malloc(size); } else { - obj = (PyObject *)PyObject_MALLOC(size); + obj = (PyObject *)PyObject_Malloc(size); } if (obj == NULL) { @@ -2707,7 +2707,7 @@ type_new(PyTypeObject *metatype, PyObject *args, PyObject *kwds) goto error; /* Silently truncate the docstring if it contains null bytes. */ len = strlen(doc_str); - tp_doc = (char *)PyObject_MALLOC(len + 1); + tp_doc = (char *)PyObject_Malloc(len + 1); if (tp_doc == NULL) { PyErr_NoMemory(); goto error; @@ -3047,7 +3047,7 @@ PyType_FromModuleAndSpec(PyObject *module, PyType_Spec *spec, PyObject *bases) continue; } size_t len = strlen(slot->pfunc)+1; - char *tp_doc = PyObject_MALLOC(len); + char *tp_doc = PyObject_Malloc(len); if (tp_doc == NULL) { type->tp_doc = NULL; PyErr_NoMemory(); diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index ba6d07a..f6473c0 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -1061,7 +1061,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length) new_size = (struct_size + (length + 1) * char_size); if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { - PyObject_DEL(_PyUnicode_UTF8(unicode)); + PyObject_Free(_PyUnicode_UTF8(unicode)); _PyUnicode_UTF8(unicode) = NULL; _PyUnicode_UTF8_LENGTH(unicode) = 0; } @@ -1072,7 +1072,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length) _Py_ForgetReference(unicode); #endif - new_unicode = (PyObject *)PyObject_REALLOC(unicode, new_size); + new_unicode = (PyObject *)PyObject_Realloc(unicode, new_size); if (new_unicode == NULL) { _Py_NewReference(unicode); PyErr_NoMemory(); @@ -1088,7 +1088,7 @@ resize_compact(PyObject *unicode, Py_ssize_t length) _PyUnicode_WSTR_LENGTH(unicode) = length; } else if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) { - PyObject_DEL(_PyUnicode_WSTR(unicode)); + PyObject_Free(_PyUnicode_WSTR(unicode)); _PyUnicode_WSTR(unicode) = NULL; if (!PyUnicode_IS_ASCII(unicode)) _PyUnicode_WSTR_LENGTH(unicode) = 0; @@ -1131,12 +1131,12 @@ resize_inplace(PyObject *unicode, Py_ssize_t length) if (!share_utf8 && _PyUnicode_HAS_UTF8_MEMORY(unicode)) { - PyObject_DEL(_PyUnicode_UTF8(unicode)); + PyObject_Free(_PyUnicode_UTF8(unicode)); _PyUnicode_UTF8(unicode) = NULL; _PyUnicode_UTF8_LENGTH(unicode) = 0; } - data = (PyObject *)PyObject_REALLOC(data, new_size); + data = (PyObject *)PyObject_Realloc(data, new_size); if (data == NULL) { PyErr_NoMemory(); return -1; @@ -1169,7 +1169,7 @@ resize_inplace(PyObject *unicode, Py_ssize_t length) } new_size = sizeof(wchar_t) * (length + 1); wstr = _PyUnicode_WSTR(unicode); - wstr = PyObject_REALLOC(wstr, new_size); + wstr = PyObject_Realloc(wstr, new_size); if (!wstr) { PyErr_NoMemory(); return -1; @@ -1259,7 +1259,7 @@ _PyUnicode_New(Py_ssize_t length) _PyUnicode_UTF8(unicode) = NULL; _PyUnicode_UTF8_LENGTH(unicode) = 0; - _PyUnicode_WSTR(unicode) = (Py_UNICODE*) PyObject_MALLOC(new_size); + _PyUnicode_WSTR(unicode) = (Py_UNICODE*) PyObject_Malloc(new_size); if (!_PyUnicode_WSTR(unicode)) { Py_DECREF(unicode); PyErr_NoMemory(); @@ -1456,7 +1456,7 @@ PyUnicode_New(Py_ssize_t size, Py_UCS4 maxchar) * PyObject_New() so we are able to allocate space for the object and * it's data buffer. */ - obj = (PyObject *) PyObject_MALLOC(struct_size + (size + 1) * char_size); + obj = (PyObject *) PyObject_Malloc(struct_size + (size + 1) * char_size); if (obj == NULL) { return PyErr_NoMemory(); } @@ -1838,7 +1838,7 @@ _PyUnicode_Ready(PyObject *unicode) return -1; if (maxchar < 256) { - _PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(_PyUnicode_WSTR_LENGTH(unicode) + 1); + _PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(_PyUnicode_WSTR_LENGTH(unicode) + 1); if (!_PyUnicode_DATA_ANY(unicode)) { PyErr_NoMemory(); return -1; @@ -1859,7 +1859,7 @@ _PyUnicode_Ready(PyObject *unicode) _PyUnicode_UTF8(unicode) = NULL; _PyUnicode_UTF8_LENGTH(unicode) = 0; } - PyObject_FREE(_PyUnicode_WSTR(unicode)); + PyObject_Free(_PyUnicode_WSTR(unicode)); _PyUnicode_WSTR(unicode) = NULL; _PyUnicode_WSTR_LENGTH(unicode) = 0; } @@ -1879,7 +1879,7 @@ _PyUnicode_Ready(PyObject *unicode) _PyUnicode_UTF8_LENGTH(unicode) = 0; #else /* sizeof(wchar_t) == 4 */ - _PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC( + _PyUnicode_DATA_ANY(unicode) = PyObject_Malloc( 2 * (_PyUnicode_WSTR_LENGTH(unicode) + 1)); if (!_PyUnicode_DATA_ANY(unicode)) { PyErr_NoMemory(); @@ -1893,7 +1893,7 @@ _PyUnicode_Ready(PyObject *unicode) _PyUnicode_STATE(unicode).kind = PyUnicode_2BYTE_KIND; _PyUnicode_UTF8(unicode) = NULL; _PyUnicode_UTF8_LENGTH(unicode) = 0; - PyObject_FREE(_PyUnicode_WSTR(unicode)); + PyObject_Free(_PyUnicode_WSTR(unicode)); _PyUnicode_WSTR(unicode) = NULL; _PyUnicode_WSTR_LENGTH(unicode) = 0; #endif @@ -1908,7 +1908,7 @@ _PyUnicode_Ready(PyObject *unicode) PyErr_NoMemory(); return -1; } - _PyUnicode_DATA_ANY(unicode) = PyObject_MALLOC(4 * (length_wo_surrogates + 1)); + _PyUnicode_DATA_ANY(unicode) = PyObject_Malloc(4 * (length_wo_surrogates + 1)); if (!_PyUnicode_DATA_ANY(unicode)) { PyErr_NoMemory(); return -1; @@ -1920,7 +1920,7 @@ _PyUnicode_Ready(PyObject *unicode) /* unicode_convert_wchar_to_ucs4() requires a ready string */ _PyUnicode_STATE(unicode).ready = 1; unicode_convert_wchar_to_ucs4(_PyUnicode_WSTR(unicode), end, unicode); - PyObject_FREE(_PyUnicode_WSTR(unicode)); + PyObject_Free(_PyUnicode_WSTR(unicode)); _PyUnicode_WSTR(unicode) = NULL; _PyUnicode_WSTR_LENGTH(unicode) = 0; #else @@ -1973,13 +1973,13 @@ unicode_dealloc(PyObject *unicode) } if (_PyUnicode_HAS_WSTR_MEMORY(unicode)) { - PyObject_DEL(_PyUnicode_WSTR(unicode)); + PyObject_Free(_PyUnicode_WSTR(unicode)); } if (_PyUnicode_HAS_UTF8_MEMORY(unicode)) { - PyObject_DEL(_PyUnicode_UTF8(unicode)); + PyObject_Free(_PyUnicode_UTF8(unicode)); } if (!PyUnicode_IS_COMPACT(unicode) && _PyUnicode_DATA_ANY(unicode)) { - PyObject_DEL(_PyUnicode_DATA_ANY(unicode)); + PyObject_Free(_PyUnicode_DATA_ANY(unicode)); } Py_TYPE(unicode)->tp_free(unicode); @@ -4199,7 +4199,7 @@ PyUnicode_AsUnicodeAndSize(PyObject *unicode, Py_ssize_t *size) PyErr_NoMemory(); return NULL; } - w = (wchar_t *) PyObject_MALLOC(sizeof(wchar_t) * (wlen + 1)); + w = (wchar_t *) PyObject_Malloc(sizeof(wchar_t) * (wlen + 1)); if (w == NULL) { PyErr_NoMemory(); return NULL; @@ -5627,7 +5627,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 = PyObject_Malloc(len + 1); if (cache == NULL) { _PyBytesWriter_Dealloc(&writer); PyErr_NoMemory(); @@ -8544,7 +8544,7 @@ PyUnicode_BuildEncodingMap(PyObject* string) } /* Create a three-level trie */ - result = PyObject_MALLOC(sizeof(struct encoding_map) + + result = PyObject_Malloc(sizeof(struct encoding_map) + 16*count2 + 128*count3 - 1); if (!result) { return PyErr_NoMemory(); @@ -15567,7 +15567,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *unicode) PyErr_NoMemory(); goto onError; } - data = PyObject_MALLOC((length + 1) * char_size); + data = PyObject_Malloc((length + 1) * char_size); if (data == NULL) { PyErr_NoMemory(); goto onError; |