mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
gh-103743: Add PyUnstable_Object_GC_NewWithExtraData (GH-103744)
Co-authored-by: Petr Viktorin <encukou@gmail.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
parent
f6314b92dc
commit
87223f32ab
6 changed files with 156 additions and 2 deletions
|
|
@ -2367,6 +2367,19 @@ _PyObject_GC_NewVar(PyTypeObject *tp, Py_ssize_t nitems)
|
|||
return op;
|
||||
}
|
||||
|
||||
PyObject *
|
||||
PyUnstable_Object_GC_NewWithExtraData(PyTypeObject *tp, size_t extra_size)
|
||||
{
|
||||
size_t presize = _PyType_PreHeaderSize(tp);
|
||||
PyObject *op = gc_alloc(_PyObject_SIZE(tp) + extra_size, presize);
|
||||
if (op == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
memset(op, 0, _PyObject_SIZE(tp) + extra_size);
|
||||
_PyObject_Init(op, tp);
|
||||
return op;
|
||||
}
|
||||
|
||||
PyVarObject *
|
||||
_PyObject_GC_Resize(PyVarObject *op, Py_ssize_t nitems)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue