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:
Neil Schemenauer 2002-03-22 15:28:30 +00:00
parent ffd5399728
commit a1a9c51a3e
1 changed files with 24 additions and 0 deletions

View File

@ -2109,3 +2109,27 @@ void _PyMalloc_Free(void *p)
PyMem_FREE(p);
}
#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);
}