[Python-checkins] python/dist/src/Python compile.c,2.293,2.294

rhettinger at users.sourceforge.net rhettinger at users.sourceforge.net
Tue Sep 16 00:27:54 EDT 2003


Update of /cvsroot/python/python/dist/src/Python
In directory sc8-pr-cvs1:/tmp/cvs-serv19599

Modified Files:
	compile.c 
Log Message:
Improve the leak fix so that PyTuple_New is only called when needed.



Index: compile.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/compile.c,v
retrieving revision 2.293
retrieving revision 2.294
diff -C2 -d -r2.293 -r2.294
*** compile.c	15 Sep 2003 21:43:16 -0000	2.293
--- compile.c	16 Sep 2003 04:27:52 -0000	2.294
***************
*** 106,110 ****
  	int flags;
  	PyObject *co;
! 	PyObject *empty;
  	PyObject *code;
  	PyObject *consts;
--- 106,110 ----
  	int flags;
  	PyObject *co;
! 	PyObject *empty = NULL;
  	PyObject *code;
  	PyObject *consts;
***************
*** 136,146 ****
  	}
  
! 	empty = PyTuple_New(0);
! 	if (empty == NULL)
! 		return NULL;
! 	if (freevars == NULL)
! 		freevars = empty;
! 	if (cellvars == NULL)
! 		cellvars = empty;
  
  	co = (PyObject *) PyCode_New(argcount, nlocals, stacksize, flags,
--- 136,148 ----
  	}
  
! 	if (freevars == NULL || cellvars == NULL) {
! 		empty = PyTuple_New(0);
! 		if (empty == NULL)
! 			return NULL;
! 		if (freevars == NULL)
! 			freevars = empty;
! 		if (cellvars == NULL)
! 			cellvars = empty;
! 	}
  
  	co = (PyObject *) PyCode_New(argcount, nlocals, stacksize, flags,
***************
*** 148,152 ****
  				      freevars, cellvars, filename, name,
  				      firstlineno, lnotab);
! 	Py_DECREF(empty);
  	return co;
  }
--- 150,154 ----
  				      freevars, cellvars, filename, name,
  				      firstlineno, lnotab);
! 	Py_XDECREF(empty);
  	return co;
  }





More information about the Python-checkins mailing list