[Python-checkins] python/dist/src/Modules mmapmodule.c,2.48,2.49

loewis at users.sourceforge.net loewis at users.sourceforge.net
Thu Mar 3 12:22:48 CET 2005


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

Modified Files:
	mmapmodule.c 
Log Message:
Patches #749830, #1144555: allow UNIX mmap size to default to current
file size.


Index: mmapmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v
retrieving revision 2.48
retrieving revision 2.49
diff -u -d -r2.48 -r2.49
--- mmapmodule.c	19 May 2004 14:39:08 -0000	2.48
+++ mmapmodule.c	3 Mar 2005 11:22:44 -0000	2.49
@@ -896,11 +896,14 @@
 	/* on OpenVMS we must ensure that all bytes are written to the file */
 	fsync(fd);
 #  endif
-	if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode) &&
-	    (size_t)map_size > st.st_size) {
-		PyErr_SetString(PyExc_ValueError, 
-				"mmap length is greater than file size");
-		return NULL;
+	if (fstat(fd, &st) == 0 && S_ISREG(st.st_mode)) {
+		if (map_size == 0) {
+			map_size = (int)st.st_size;
+		} else if ((size_t)map_size > st.st_size) {
+			PyErr_SetString(PyExc_ValueError, 
+					"mmap length is greater than file size");
+			return NULL;
+		}
 	}
 #endif
 	m_obj = PyObject_New (mmap_object, &mmap_object_type);



More information about the Python-checkins mailing list