diff --git a/Makefile.pre.in b/Makefile.pre.in index 5bed5459522..8a10a10dd3d 100644 --- a/Makefile.pre.in +++ b/Makefile.pre.in @@ -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 diff --git a/Objects/object.c b/Objects/object.c index 494e8402376..6ec8c8b59c4 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 7fb0d8bc86e..a3f4cf87adf 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); +} diff --git a/PCbuild/pythoncore.dsp b/PCbuild/pythoncore.dsp index 6495952c203..b91355f22cc 100644 --- a/PCbuild/pythoncore.dsp +++ b/PCbuild/pythoncore.dsp @@ -1268,6 +1268,21 @@ SOURCE=..\Objects\object.c # End Source File # Begin Source File +SOURCE=..\Objects\obmalloc.c + +!IF "$(CFG)" == "pythoncore - Win32 Release" + +!ELSEIF "$(CFG)" == "pythoncore - Win32 Debug" + +!ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Debug" + +!ELSEIF "$(CFG)" == "pythoncore - Win32 Alpha Release" + +!ENDIF + +# End Source File +# Begin Source File + SOURCE=..\Modules\operator.c !IF "$(CFG)" == "pythoncore - Win32 Release"