]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Build obmalloc.c directly instead of #include'ing from object.c.
authorTim Peters <tim.peters@gmail.com>
Sat, 23 Mar 2002 00:20:15 +0000 (00:20 +0000)
committerTim Peters <tim.peters@gmail.com>
Sat, 23 Mar 2002 00:20:15 +0000 (00:20 +0000)
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.

Makefile.pre.in
Objects/object.c
Objects/obmalloc.c
PCbuild/pythoncore.dsp

index 5bed545952215502a826e8538057c4553e4c18be..8a10a10dd3da2771e28965afbadcc3a1f9a0d9b5 100644 (file)
@@ -263,6 +263,7 @@ OBJECT_OBJS=        \
                Objects/methodobject.o \
                Objects/moduleobject.o \
                Objects/object.o \
+               Objects/obmalloc.o \
                Objects/rangeobject.o \
                Objects/sliceobject.o \
                Objects/stringobject.o \
@@ -424,8 +425,6 @@ Python/getplatform.o: $(srcdir)/Python/getplatform.c
 Python/importdl.o: $(srcdir)/Python/importdl.c
                $(CC) -c $(CFLAGS) $(CPPFLAGS) -I$(DLINCLDIR) -o $@ $(srcdir)/Python/importdl.c
 
-Objects/object.o: $(srcdir)/Objects/object.c $(srcdir)/Objects/obmalloc.c
-
 Objects/unicodectype.o:        $(srcdir)/Objects/unicodectype.c \
                                $(srcdir)/Objects/unicodetype_db.h
 
index 494e840237603fb106c5bfef86019ec632c7ff88..6ec8c8b59c46f142b681337c7c55b6008e1a1104 100644 (file)
@@ -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);
-}
index 7fb0d8bc86e4c1c512f275d2877b4c92b82d1c40..a3f4cf87adf6eeba98f25b00141fe4b7b0588c24 100644 (file)
@@ -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);
+}
index 6495952c203052e6336aca56caf2b4949564b0f3..b91355f22cc429a4167f71cec8a8717ffe29a72c 100644 (file)
@@ -1268,6 +1268,21 @@ SOURCE=..\Objects\object.c
 # End Source File\r
 # Begin Source File\r
 \r
+SOURCE=..\Objects\obmalloc.c\r
+\r
+!IF  "$(CFG)" == "pythoncore - Win32 Release"\r
+\r
+!ELSEIF  "$(CFG)" == "pythoncore - Win32 Debug"\r
+\r
+!ELSEIF  "$(CFG)" == "pythoncore - Win32 Alpha Debug"\r
+\r
+!ELSEIF  "$(CFG)" == "pythoncore - Win32 Alpha Release"\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
 SOURCE=..\Modules\operator.c\r
 \r
 !IF  "$(CFG)" == "pythoncore - Win32 Release"\r