summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-03-22 15:28:30 (GMT)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>2002-03-22 15:28:30 (GMT)
commita1a9c51a3ef06614413f45d51e65588bcd0793f2 (patch)
tree2112db2734a96ef68704d53b29b33cf0d28938d9 /Objects/object.c
parentffd53997286973bc6abcfdc0fae92aaa88b51f67 (diff)
downloadcpython-a1a9c51a3ef06614413f45d51e65588bcd0793f2.zip
cpython-a1a9c51a3ef06614413f45d51e65588bcd0793f2.tar.gz
cpython-a1a9c51a3ef06614413f45d51e65588bcd0793f2.tar.bz2
Add pymalloc object memory management functions. These must be
available even if pymalloc is disabled since extension modules might use them.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 1602e89..494e840 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -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);
+}