[Python-checkins] python/dist/src/Objects listobject.c,2.204,2.205

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Wed May 5 02:28:19 EDT 2004


Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25429

Modified Files:
	listobject.c 
Log Message:
Nits:
- Neatened the braces in PyList_New().
- Made sure "indexerr" was initialized to NULL.
- Factored if blocks in PyList_Append().
- Made sure "allocated" is initialized in list_init().



Index: listobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/listobject.c,v
retrieving revision 2.204
retrieving revision 2.205
diff -C2 -d -r2.204 -r2.205
*** listobject.c	5 May 2004 05:37:53 -0000	2.204
--- listobject.c	5 May 2004 06:28:16 -0000	2.205
***************
*** 66,72 ****
  	nbytes = size * sizeof(PyObject *);
  	/* Check for overflow */
! 	if (nbytes / sizeof(PyObject *) != (size_t)size) {
  		return PyErr_NoMemory();
- 	}
  	if (num_free_lists) {
  		num_free_lists--;
--- 66,71 ----
  	nbytes = size * sizeof(PyObject *);
  	/* Check for overflow */
! 	if (nbytes / sizeof(PyObject *) != (size_t)size)
  		return PyErr_NoMemory();
  	if (num_free_lists) {
  		num_free_lists--;
***************
*** 78,89 ****
  			return NULL;
  	}
! 	if (size <= 0) {
  		op->ob_item = NULL;
- 	}
  	else {
  		op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
! 		if (op->ob_item == NULL) {
  			return PyErr_NoMemory();
- 		}
  		memset(op->ob_item, 0, sizeof(*op->ob_item) * size);
  	}
--- 77,86 ----
  			return NULL;
  	}
! 	if (size <= 0)
  		op->ob_item = NULL;
  	else {
  		op->ob_item = (PyObject **) PyMem_MALLOC(nbytes);
! 		if (op->ob_item == NULL)
  			return PyErr_NoMemory();
  		memset(op->ob_item, 0, sizeof(*op->ob_item) * size);
  	}
***************
*** 105,109 ****
  }
  
! static PyObject *indexerr;
  
  PyObject *
--- 102,106 ----
  }
  
! static PyObject *indexerr = NULL;
  
  PyObject *
***************
*** 214,226 ****
  PyList_Append(PyObject *op, PyObject *newitem)
  {
! 	if (!PyList_Check(op)) {
! 		PyErr_BadInternalCall();
! 		return -1;
! 	}
! 	if (newitem == NULL) {
! 		PyErr_BadInternalCall();
! 		return -1;
! 	}
! 	return app1((PyListObject *)op, newitem);
  }
  
--- 211,218 ----
  PyList_Append(PyObject *op, PyObject *newitem)
  {
! 	if (PyList_Check(op) && (newitem != NULL))
! 		return app1((PyListObject *)op, newitem);
! 	PyErr_BadInternalCall();
! 	return -1;
  }
  
***************
*** 2315,2318 ****
--- 2307,2311 ----
  		return -1;
  	/* Empty previous contents */
+ 	self->allocated = self->ob_size;
  	if (self->ob_size != 0) {
  		if (list_ass_slice(self, 0, self->ob_size, (PyObject *)NULL) != 0)




More information about the Python-checkins mailing list