
Update of /cvsroot/python/python/dist/src/Objects In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11098/Objects Modified Files: listobject.c Log Message: list_ass_slice(): The difference between "recycle" and "recycled" was impossible to remember, so renamed one to something obvious. Headed off potential signed-vs-unsigned compiler complaints I introduced by changing the type of a vrbl to unsigned. Removed the need for the tedious explanation about "backward pointer loops" by looping on an int instead. Index: listobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v retrieving revision 2.216 retrieving revision 2.217 diff -C2 -d -r2.216 -r2.217 *** listobject.c 31 Jul 2004 02:24:20 -0000 2.216 --- listobject.c 31 Jul 2004 02:54:42 -0000 2.217 *************** *** 529,534 **** we temporarily copy the items that are deleted from the list. :-( */ ! PyObject *recycled[8]; ! PyObject **recycle = recycled; /* will allocate more if needed */ PyObject **item; PyObject **vitem = NULL; --- 529,534 ---- we temporarily copy the items that are deleted from the list. :-( */ ! PyObject *recycle_on_stack[8]; ! PyObject **recycle = recycle_on_stack; /* will allocate more if needed */ PyObject **item; PyObject **vitem = NULL; *************** *** 537,541 **** int norig; /* # of elements in list getting replaced */ int d; /* Change in size */ ! int k; /* Loop index */ size_t s; int result = -1; /* guilty until proved innocent */ --- 537,541 ---- int norig; /* # of elements in list getting replaced */ int d; /* Change in size */ ! int k; size_t s; int result = -1; /* guilty until proved innocent */ *************** *** 579,583 **** /* recycle the items that we are about to remove */ s = norig * sizeof(PyObject *); ! if (s > sizeof(recycled)) { recycle = (PyObject **)PyMem_MALLOC(s); if (recycle == NULL) { --- 579,583 ---- /* recycle the items that we are about to remove */ s = norig * sizeof(PyObject *); ! if (s > sizeof(recycle_on_stack)) { recycle = (PyObject **)PyMem_MALLOC(s); if (recycle == NULL) { *************** *** 595,604 **** } else if (d > 0) { /* Insert d items */ ! s = a->ob_size; ! if (list_resize(a, s+d) < 0) goto Error; item = a->ob_item; memmove(&item[ihigh+d], &item[ihigh], ! (s - ihigh)*sizeof(PyObject *)); } for (k = 0; k < n; k++, ilow++) { --- 595,604 ---- } else if (d > 0) { /* Insert d items */ ! k = a->ob_size; ! if (list_resize(a, k+d) < 0) goto Error; item = a->ob_item; memmove(&item[ihigh+d], &item[ihigh], ! (k - ihigh)*sizeof(PyObject *)); } for (k = 0; k < n; k++, ilow++) { *************** *** 607,622 **** item[ilow] = w; } ! /* Convoluted: there's some obscure reason for wanting to do ! * the decrefs "backwards", but C doesn't guarantee you can compute ! * a pointer to one slot *before* an allocated vector. So checking ! * for item >= recycle is incorrect. ! */ ! for (item = recycle + norig; item > recycle; ) { ! --item; ! Py_XDECREF(*item); ! } result = 0; Error: ! if (recycle != recycled) PyMem_FREE(recycle); Py_XDECREF(v_as_SF); --- 607,615 ---- item[ilow] = w; } ! for (k = norig - 1; k >= 0; --k) ! Py_XDECREF(recycle[k]); result = 0; Error: ! if (recycle != recycle_on_stack) PyMem_FREE(recycle); Py_XDECREF(v_as_SF);