]> granicus.if.org Git - python/commitdiff
Use pymalloc if it's enabled.
authorNeil Schemenauer <nascheme@enme.ucalgary.ca>
Fri, 22 Mar 2002 15:33:15 +0000 (15:33 +0000)
committerNeil Schemenauer <nascheme@enme.ucalgary.ca>
Fri, 22 Mar 2002 15:33:15 +0000 (15:33 +0000)
Modules/gcmodule.c
Objects/dictobject.c
Objects/rangeobject.c
Objects/sliceobject.c
Objects/stringobject.c
Objects/structseq.c
Objects/unicodeobject.c

index d883b91fe23e2f260c6aaa4772bbae9e13a1e59a..23a137edb741e6bfd75c9784b52e26cae779b354 100644 (file)
@@ -829,7 +829,7 @@ _PyObject_GC_Malloc(PyTypeObject *tp, int nitems)
        const size_t basicsize = _PyObject_VAR_SIZE(tp, nitems);
 #ifdef WITH_CYCLE_GC
        const size_t nbytes = sizeof(PyGC_Head) + basicsize;
-       PyGC_Head *g = PyObject_MALLOC(nbytes);
+       PyGC_Head *g = _PyMalloc_MALLOC(nbytes);
        if (g == NULL)
                return (PyObject *)PyErr_NoMemory();
        g->gc.gc_next = NULL;
@@ -845,7 +845,7 @@ _PyObject_GC_Malloc(PyTypeObject *tp, int nitems)
        }
        op = FROM_GC(g);
 #else
-       op = PyObject_MALLOC(basicsize);
+       op = _PyMalloc_MALLOC(basicsize);
        if (op == NULL)
                return (PyObject *)PyErr_NoMemory();
 
@@ -896,9 +896,9 @@ _PyObject_GC_Del(PyObject *op)
        if (allocated > 0) {
                allocated--;
        }
-       PyObject_FREE(g);
+       _PyMalloc_FREE(g);
 #else
-       PyObject_FREE(op);
+       _PyMalloc_FREE(op);
 #endif
 }
 
index e843e760cb90dc5dbb7672967f9699a286ce95ee..5803c574061a24020492ba0183e6780874c05e6c 100644 (file)
@@ -1914,7 +1914,7 @@ static PyObject *
 dictiter_new(dictobject *dict, binaryfunc select)
 {
        dictiterobject *di;
-       di = PyObject_NEW(dictiterobject, &PyDictIter_Type);
+       di = PyMalloc_New(dictiterobject, &PyDictIter_Type);
        if (di == NULL)
                return NULL;
        Py_INCREF(dict);
@@ -1929,7 +1929,7 @@ static void
 dictiter_dealloc(dictiterobject *di)
 {
        Py_DECREF(di->di_dict);
-       PyObject_DEL(di);
+       PyMalloc_Del(di);
 }
 
 static PyObject *
index da791fa4060e21ca40d9a6f115b7c33e03d0b29e..fa7e6609d11ee1b100ea1a237cfad3e16b085e25 100644 (file)
@@ -60,7 +60,7 @@ PyObject *
 PyRange_New(long start, long len, long step, int reps)
 {
        long totlen = -1;
-       rangeobject *obj = PyObject_NEW(rangeobject, &PyRange_Type);
+       rangeobject *obj = PyMalloc_New(rangeobject, &PyRange_Type);
 
        if (obj == NULL)
                return NULL;
@@ -104,7 +104,7 @@ PyRange_New(long start, long len, long step, int reps)
 static void
 range_dealloc(rangeobject *r)
 {
-       PyObject_DEL(r);
+       PyMalloc_Del(r);
 }
 
 static PyObject *
index 42cbf2400b517411efe4784db4aab575de030147..108ab275c126cccb0082031300456bbd7f768196 100644 (file)
@@ -60,7 +60,7 @@ PyObject _Py_EllipsisObject = {
 PyObject *
 PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
 {
-       PySliceObject *obj = PyObject_NEW(PySliceObject, &PySlice_Type);
+       PySliceObject *obj = PyMalloc_New(PySliceObject, &PySlice_Type);
 
        if (obj == NULL)
                return NULL;
@@ -115,7 +115,7 @@ slice_dealloc(PySliceObject *r)
        Py_DECREF(r->step);
        Py_DECREF(r->start);
        Py_DECREF(r->stop);
-       PyObject_DEL(r);
+       PyMalloc_Del(r);
 }
 
 static PyObject *
index 4fb5e9361bfc8325ad25cb4af5ad810ee567941f..b39d9e51fafde1eface71c644a366e43541caab7 100644 (file)
@@ -68,7 +68,7 @@ PyString_FromStringAndSize(const char *str, int size)
 
        /* PyObject_NewVar is inlined */
        op = (PyStringObject *)
-               PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
+               _PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
        if (op == NULL)
                return PyErr_NoMemory();
        PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -131,7 +131,7 @@ PyString_FromString(const char *str)
 
        /* PyObject_NewVar is inlined */
        op = (PyStringObject *)
-               PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
+               _PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
        if (op == NULL)
                return PyErr_NoMemory();
        PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -733,7 +733,7 @@ string_concat(register PyStringObject *a, register PyObject *bb)
        size = a->ob_size + b->ob_size;
        /* PyObject_NewVar is inlined */
        op = (PyStringObject *)
-               PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
+               _PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
        if (op == NULL)
                return PyErr_NoMemory();
        PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -780,7 +780,7 @@ string_repeat(register PyStringObject *a, register int n)
                return NULL;
        }
        op = (PyStringObject *)
-               PyObject_MALLOC(sizeof(PyStringObject) + nbytes);
+               _PyMalloc_MALLOC(sizeof(PyStringObject) + nbytes);
        if (op == NULL)
                return PyErr_NoMemory();
        PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -2789,7 +2789,7 @@ PyTypeObject PyString_Type = {
        0,                                      /* tp_init */
        0,                                      /* tp_alloc */
        string_new,                             /* tp_new */
-       _PyObject_Del,                          /* tp_free */
+       _PyMalloc_Del,                          /* tp_free */
 };
 
 void
@@ -2841,10 +2841,10 @@ _PyString_Resize(PyObject **pv, int newsize)
 #endif
        _Py_ForgetReference(v);
        *pv = (PyObject *)
-               PyObject_REALLOC((char *)v,
+               _PyMalloc_REALLOC((char *)v,
                        sizeof(PyStringObject) + newsize * sizeof(char));
        if (*pv == NULL) {
-               PyObject_DEL(v);
+               PyMalloc_Del(v);
                PyErr_NoMemory();
                return -1;
        }
index 377dfebd2ed5599ba78cdc24381b57e8c4ecf601..7231ce1ec6eb646bff8f1aa6668f4f78b2a2b2a1 100644 (file)
@@ -22,7 +22,7 @@ PyStructSequence_New(PyTypeObject *type)
 {
        PyStructSequence *obj;
        
-       obj = PyObject_New(PyStructSequence, type);
+       obj = PyMalloc_New(PyStructSequence, type);
        obj->ob_size = VISIBLE_SIZE_TP(type);
 
        return (PyObject*) obj;
@@ -37,7 +37,7 @@ structseq_dealloc(PyStructSequence *obj)
        for (i = 0; i < size; ++i) {
                Py_XDECREF(obj->ob_item[i]);
        }
-       PyObject_FREE(obj);
+       PyMalloc_Del(obj);
 }
 
 static int
index 978ac54c923d2dbd37af3d2831e2759439bbf030..73d5d9de0cca76fab94ddf9f560709fa3738d19f 100644 (file)
@@ -201,7 +201,7 @@ PyUnicodeObject *_PyUnicode_New(int length)
         PyObject_INIT(unicode, &PyUnicode_Type);
     }
     else {
-        unicode = PyObject_NEW(PyUnicodeObject, &PyUnicode_Type);
+        unicode = PyMalloc_New(PyUnicodeObject, &PyUnicode_Type);
         if (unicode == NULL)
             return NULL;
        unicode->str = PyMem_NEW(Py_UNICODE, length + 1);
@@ -219,7 +219,7 @@ PyUnicodeObject *_PyUnicode_New(int length)
 
  onError:
     _Py_ForgetReference((PyObject *)unicode);
-    PyObject_DEL(unicode);
+    PyMalloc_Del(unicode);
     return NULL;
 }
 
@@ -5711,7 +5711,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
        pnew->str = PyMem_NEW(Py_UNICODE, n+1);
        if (pnew->str == NULL) {
                _Py_ForgetReference((PyObject *)pnew);
-               PyObject_DEL(pnew);
+               PyMalloc_Del(pnew);
                return NULL;
        }
        Py_UNICODE_COPY(pnew->str, tmp->str, n+1);
@@ -5769,7 +5769,7 @@ PyTypeObject PyUnicode_Type = {
     0,                                 /* tp_init */
     0,                                 /* tp_alloc */
     unicode_new,                       /* tp_new */
-    _PyObject_Del,                     /* tp_free */
+    _PyMalloc_Del,                     /* tp_free */
 };
 
 /* Initialize the Unicode implementation */
@@ -5811,7 +5811,7 @@ _PyUnicode_Fini(void)
        if (v->str)
            PyMem_DEL(v->str);
        Py_XDECREF(v->defenc);
-       PyObject_DEL(v);
+       PyMalloc_Del(v);
     }
     unicode_freelist = NULL;
     unicode_freelist_size = 0;