Skip to content

Commit f47269b

Browse files
author
nascheme
committed
Use pymalloc if it's enabled.
git-svn-id: http://svn.python.org/projects/python/trunk@25808 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent aa578e8 commit f47269b

File tree

7 files changed

+24
-24
lines changed

7 files changed

+24
-24
lines changed

Modules/gcmodule.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ _PyObject_GC_Malloc(PyTypeObject *tp, int nitems)
829829
const size_t basicsize = _PyObject_VAR_SIZE(tp, nitems);
830830
#ifdef WITH_CYCLE_GC
831831
const size_t nbytes = sizeof(PyGC_Head) + basicsize;
832-
PyGC_Head *g = PyObject_MALLOC(nbytes);
832+
PyGC_Head *g = _PyMalloc_MALLOC(nbytes);
833833
if (g == NULL)
834834
return (PyObject *)PyErr_NoMemory();
835835
g->gc.gc_next = NULL;
@@ -845,7 +845,7 @@ _PyObject_GC_Malloc(PyTypeObject *tp, int nitems)
845845
}
846846
op = FROM_GC(g);
847847
#else
848-
op = PyObject_MALLOC(basicsize);
848+
op = _PyMalloc_MALLOC(basicsize);
849849
if (op == NULL)
850850
return (PyObject *)PyErr_NoMemory();
851851

@@ -896,9 +896,9 @@ _PyObject_GC_Del(PyObject *op)
896896
if (allocated > 0) {
897897
allocated--;
898898
}
899-
PyObject_FREE(g);
899+
_PyMalloc_FREE(g);
900900
#else
901-
PyObject_FREE(op);
901+
_PyMalloc_FREE(op);
902902
#endif
903903
}
904904

Objects/dictobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,7 +1914,7 @@ static PyObject *
19141914
dictiter_new(dictobject *dict, binaryfunc select)
19151915
{
19161916
dictiterobject *di;
1917-
di = PyObject_NEW(dictiterobject, &PyDictIter_Type);
1917+
di = PyMalloc_New(dictiterobject, &PyDictIter_Type);
19181918
if (di == NULL)
19191919
return NULL;
19201920
Py_INCREF(dict);
@@ -1929,7 +1929,7 @@ static void
19291929
dictiter_dealloc(dictiterobject *di)
19301930
{
19311931
Py_DECREF(di->di_dict);
1932-
PyObject_DEL(di);
1932+
PyMalloc_Del(di);
19331933
}
19341934

19351935
static PyObject *

Objects/rangeobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ PyObject *
6060
PyRange_New(long start, long len, long step, int reps)
6161
{
6262
long totlen = -1;
63-
rangeobject *obj = PyObject_NEW(rangeobject, &PyRange_Type);
63+
rangeobject *obj = PyMalloc_New(rangeobject, &PyRange_Type);
6464

6565
if (obj == NULL)
6666
return NULL;
@@ -104,7 +104,7 @@ PyRange_New(long start, long len, long step, int reps)
104104
static void
105105
range_dealloc(rangeobject *r)
106106
{
107-
PyObject_DEL(r);
107+
PyMalloc_Del(r);
108108
}
109109

110110
static PyObject *

Objects/sliceobject.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ PyObject _Py_EllipsisObject = {
6060
PyObject *
6161
PySlice_New(PyObject *start, PyObject *stop, PyObject *step)
6262
{
63-
PySliceObject *obj = PyObject_NEW(PySliceObject, &PySlice_Type);
63+
PySliceObject *obj = PyMalloc_New(PySliceObject, &PySlice_Type);
6464

6565
if (obj == NULL)
6666
return NULL;
@@ -115,7 +115,7 @@ slice_dealloc(PySliceObject *r)
115115
Py_DECREF(r->step);
116116
Py_DECREF(r->start);
117117
Py_DECREF(r->stop);
118-
PyObject_DEL(r);
118+
PyMalloc_Del(r);
119119
}
120120

121121
static PyObject *

Objects/stringobject.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ PyString_FromStringAndSize(const char *str, int size)
6868

6969
/* PyObject_NewVar is inlined */
7070
op = (PyStringObject *)
71-
PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
71+
_PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
7272
if (op == NULL)
7373
return PyErr_NoMemory();
7474
PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -131,7 +131,7 @@ PyString_FromString(const char *str)
131131

132132
/* PyObject_NewVar is inlined */
133133
op = (PyStringObject *)
134-
PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
134+
_PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
135135
if (op == NULL)
136136
return PyErr_NoMemory();
137137
PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -733,7 +733,7 @@ string_concat(register PyStringObject *a, register PyObject *bb)
733733
size = a->ob_size + b->ob_size;
734734
/* PyObject_NewVar is inlined */
735735
op = (PyStringObject *)
736-
PyObject_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
736+
_PyMalloc_MALLOC(sizeof(PyStringObject) + size * sizeof(char));
737737
if (op == NULL)
738738
return PyErr_NoMemory();
739739
PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -780,7 +780,7 @@ string_repeat(register PyStringObject *a, register int n)
780780
return NULL;
781781
}
782782
op = (PyStringObject *)
783-
PyObject_MALLOC(sizeof(PyStringObject) + nbytes);
783+
_PyMalloc_MALLOC(sizeof(PyStringObject) + nbytes);
784784
if (op == NULL)
785785
return PyErr_NoMemory();
786786
PyObject_INIT_VAR(op, &PyString_Type, size);
@@ -2789,7 +2789,7 @@ PyTypeObject PyString_Type = {
27892789
0, /* tp_init */
27902790
0, /* tp_alloc */
27912791
string_new, /* tp_new */
2792-
_PyObject_Del, /* tp_free */
2792+
_PyMalloc_Del, /* tp_free */
27932793
};
27942794

27952795
void
@@ -2841,10 +2841,10 @@ _PyString_Resize(PyObject **pv, int newsize)
28412841
#endif
28422842
_Py_ForgetReference(v);
28432843
*pv = (PyObject *)
2844-
PyObject_REALLOC((char *)v,
2844+
_PyMalloc_REALLOC((char *)v,
28452845
sizeof(PyStringObject) + newsize * sizeof(char));
28462846
if (*pv == NULL) {
2847-
PyObject_DEL(v);
2847+
PyMalloc_Del(v);
28482848
PyErr_NoMemory();
28492849
return -1;
28502850
}

Objects/structseq.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ PyStructSequence_New(PyTypeObject *type)
2222
{
2323
PyStructSequence *obj;
2424

25-
obj = PyObject_New(PyStructSequence, type);
25+
obj = PyMalloc_New(PyStructSequence, type);
2626
obj->ob_size = VISIBLE_SIZE_TP(type);
2727

2828
return (PyObject*) obj;
@@ -37,7 +37,7 @@ structseq_dealloc(PyStructSequence *obj)
3737
for (i = 0; i < size; ++i) {
3838
Py_XDECREF(obj->ob_item[i]);
3939
}
40-
PyObject_FREE(obj);
40+
PyMalloc_Del(obj);
4141
}
4242

4343
static int

Objects/unicodeobject.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ PyUnicodeObject *_PyUnicode_New(int length)
201201
PyObject_INIT(unicode, &PyUnicode_Type);
202202
}
203203
else {
204-
unicode = PyObject_NEW(PyUnicodeObject, &PyUnicode_Type);
204+
unicode = PyMalloc_New(PyUnicodeObject, &PyUnicode_Type);
205205
if (unicode == NULL)
206206
return NULL;
207207
unicode->str = PyMem_NEW(Py_UNICODE, length + 1);
@@ -219,7 +219,7 @@ PyUnicodeObject *_PyUnicode_New(int length)
219219

220220
onError:
221221
_Py_ForgetReference((PyObject *)unicode);
222-
PyObject_DEL(unicode);
222+
PyMalloc_Del(unicode);
223223
return NULL;
224224
}
225225

@@ -5711,7 +5711,7 @@ unicode_subtype_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
57115711
pnew->str = PyMem_NEW(Py_UNICODE, n+1);
57125712
if (pnew->str == NULL) {
57135713
_Py_ForgetReference((PyObject *)pnew);
5714-
PyObject_DEL(pnew);
5714+
PyMalloc_Del(pnew);
57155715
return NULL;
57165716
}
57175717
Py_UNICODE_COPY(pnew->str, tmp->str, n+1);
@@ -5769,7 +5769,7 @@ PyTypeObject PyUnicode_Type = {
57695769
0, /* tp_init */
57705770
0, /* tp_alloc */
57715771
unicode_new, /* tp_new */
5772-
_PyObject_Del, /* tp_free */
5772+
_PyMalloc_Del, /* tp_free */
57735773
};
57745774

57755775
/* Initialize the Unicode implementation */
@@ -5811,7 +5811,7 @@ _PyUnicode_Fini(void)
58115811
if (v->str)
58125812
PyMem_DEL(v->str);
58135813
Py_XDECREF(v->defenc);
5814-
PyObject_DEL(v);
5814+
PyMalloc_Del(v);
58155815
}
58165816
unicode_freelist = NULL;
58175817
unicode_freelist_size = 0;

0 commit comments

Comments
 (0)