mirror of https://github.com/python/cpython.git
Add pymalloc object memory management functions. These must be
available even if pymalloc is disabled since extension modules might use them.
This commit is contained in:
parent
ffd5399728
commit
a1a9c51a3e
|
@ -2109,3 +2109,27 @@ void _PyMalloc_Free(void *p)
|
||||||
PyMem_FREE(p);
|
PyMem_FREE(p);
|
||||||
}
|
}
|
||||||
#endif /* !WITH_PYMALLOC */
|
#endif /* !WITH_PYMALLOC */
|
||||||
|
|
||||||
|
PyObject *_PyMalloc_New(PyTypeObject *tp)
|
||||||
|
{
|
||||||
|
PyObject *op;
|
||||||
|
op = (PyObject *) _PyMalloc_MALLOC(_PyObject_SIZE(tp));
|
||||||
|
if (op == NULL)
|
||||||
|
return PyErr_NoMemory();
|
||||||
|
return PyObject_INIT(op, tp);
|
||||||
|
}
|
||||||
|
|
||||||
|
PyVarObject *_PyMalloc_NewVar(PyTypeObject *tp, int nitems)
|
||||||
|
{
|
||||||
|
PyVarObject *op;
|
||||||
|
const size_t size = _PyObject_VAR_SIZE(tp, nitems);
|
||||||
|
op = (PyVarObject *) _PyMalloc_MALLOC(size);
|
||||||
|
if (op == NULL)
|
||||||
|
return (PyVarObject *)PyErr_NoMemory();
|
||||||
|
return PyObject_INIT_VAR(op, tp, nitems);
|
||||||
|
}
|
||||||
|
|
||||||
|
void _PyMalloc_Del(PyObject *op)
|
||||||
|
{
|
||||||
|
_PyMalloc_FREE(op);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue