[Python-checkins] python/dist/src/Python asdl.c,1.1.2.6,1.1.2.7

nascheme at users.sourceforge.net nascheme at users.sourceforge.net
Fri Apr 15 04:11:26 CEST 2005


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

Modified Files:
      Tag: ast-branch
	asdl.c 
Log Message:
Initialize asdl_seq with NULLs.  That makes error handling easier
since the sequence may be partly filled when an error occurs.


Index: asdl.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/Attic/asdl.c,v
retrieving revision 1.1.2.6
retrieving revision 1.1.2.7
diff -u -d -r1.1.2.6 -r1.1.2.7
--- asdl.c	13 Apr 2005 19:44:37 -0000	1.1.2.6
+++ asdl.c	15 Apr 2005 02:11:24 -0000	1.1.2.7
@@ -5,16 +5,16 @@
 asdl_seq_new(int size)
 {
 	asdl_seq *seq = NULL;
+	size_t n = sizeof(asdl_seq) +
+			(size ? (sizeof(void *) * (size - 1)) : 0);
 
-	seq = (asdl_seq *)PyObject_Malloc(sizeof(asdl_seq)
-				+ (size ? (sizeof(void *) * (size - 1)) : 0));
-
+	seq = (asdl_seq *)PyObject_Malloc(n);
 	if (!seq) {
 		PyErr_SetString(PyExc_MemoryError, "no memory");
 		return NULL;
 	}
+	memset(seq, 0, n);
 	seq->size = size;
-	seq->offset = 0;
 	return seq;
 }
 



More information about the Python-checkins mailing list