summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2002-03-23 00:20:15 (GMT)
committerTim Peters <tim.peters@gmail.com>2002-03-23 00:20:15 (GMT)
commit1221c0a435135143632d986e861d9243d3d2ad35 (patch)
tree402bea358ba5042ac020bf9cd27f725abc5974d3 /Objects
parentc24ea08644279224a7a8be419648261f9566c9b3 (diff)
downloadcpython-1221c0a435135143632d986e861d9243d3d2ad35.zip
cpython-1221c0a435135143632d986e861d9243d3d2ad35.tar.gz
cpython-1221c0a435135143632d986e861d9243d3d2ad35.tar.bz2
Build obmalloc.c directly instead of #include'ing from object.c.
Also move all _PyMalloc_XXX entry points into obmalloc.c. The Windows build works fine. The Unix build is changed here (Makefile.pre.in), but not tested. No other platform's build process has been fiddled.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/object.c43
-rw-r--r--Objects/obmalloc.c50
2 files changed, 50 insertions, 43 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 494e840..6ec8c8b 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2090,46 +2090,3 @@ _PyTrash_destroy_chain(void)
--_PyTrash_delete_nesting;
}
}
-
-#ifdef WITH_PYMALLOC
-#include "obmalloc.c"
-#else
-void *_PyMalloc_Malloc(size_t n)
-{
- return PyMem_MALLOC(n);
-}
-
-void *_PyMalloc_Realloc(void *p, size_t n)
-{
- return PyMem_REALLOC(p, n);
-}
-
-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);
-}
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 7fb0d8b..a3f4cf8 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -1,3 +1,7 @@
+#include "Python.h"
+
+#ifdef WITH_PYMALLOC
+
/* An object allocator for Python.
Here is an introduction to the layers of the Python memory architecture,
@@ -636,3 +640,49 @@ _PyMalloc_Calloc(size_t nbel, size_t elsz)
}
*/
+#else /* ! WITH_PYMALLOC */
+void
+*_PyMalloc_Malloc(size_t n)
+{
+ return PyMem_MALLOC(n);
+}
+
+void
+*_PyMalloc_Realloc(void *p, size_t n)
+{
+ return PyMem_REALLOC(p, n);
+}
+
+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);
+}