PyList_New(Py_ssize_t size)
{
PyListObject *op;
- size_t nbytes;
#ifdef SHOW_ALLOC_COUNT
static int initialized = 0;
if (!initialized) {
PyErr_BadInternalCall();
return NULL;
}
- /* Check for overflow without an actual overflow,
- * which can cause compiler to optimise out */
- if ((size_t)size > PY_SIZE_MAX / sizeof(PyObject *))
- return PyErr_NoMemory();
- nbytes = size * sizeof(PyObject *);
if (numfree) {
numfree--;
op = free_list[numfree];
if (size <= 0)
op->ob_item = NULL;
else {
- op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
+ op->ob_item = (PyObject **) PyMem_Calloc(size, sizeof(PyObject *));
if (op->ob_item == NULL) {
Py_DECREF(op);
return PyErr_NoMemory();
}
- memset(op->ob_item, 0, nbytes);
}
Py_SIZE(op) = size;
op->allocated = size;
step = -step;
}
- assert((size_t)slicelength <=
- PY_SIZE_MAX / sizeof(PyObject*));
-
garbage = (PyObject**)
PyMem_MALLOC(slicelength*sizeof(PyObject*));
if (!garbage) {