[Python-checkins] python/nondist/sandbox/twister _random.c,1.3,1.4

rhettinger@users.sourceforge.net rhettinger@users.sourceforge.net
2002年12月25日 13:01:06 -0800


Update of /cvsroot/python/python/nondist/sandbox/twister
In directory sc8-pr-cvs1:/tmp/cvs-serv10003
Modified Files:
	_random.c 
Log Message:
Followed Just's suggestion to use PyMem_Malloc/Free instead of 
PyMem_MALLOC/FREE. Slowed it down a tiny (for the function call), 
but addes a tiny bit of type checking (size_t).
Index: _random.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/twister/_random.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** _random.c	25 Dec 2002 20:47:19 -0000	1.3
--- _random.c	25 Dec 2002 21:01:04 -0000	1.4
***************
*** 263,267 ****
 
 	keylength = PyList_Size(split);
! 	key = (unsigned long *) PyMem_MALLOC(keylength * sizeof(unsigned long));
 	if (key == NULL)
 		goto Done;
--- 263,267 ----
 
 	keylength = PyList_Size(split);
! 	key = (unsigned long *) PyMem_Malloc(keylength * sizeof(unsigned long));
 	if (key == NULL)
 		goto Done;
***************
*** 275,279 ****
 	}
 	result = init_by_array(self, key, keylength);
! 	PyMem_FREE(key);
 Done:
 	Py_XDECREF(masklower);
--- 275,279 ----
 	}
 	result = init_by_array(self, key, keylength);
! 	PyMem_Free(key);
 Done:
 	Py_XDECREF(masklower);

AltStyle によって変換されたページ (->オリジナル) /