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

birkenfeld@users.sourceforge.net birkenfeld at users.sourceforge.net
Wed Aug 24 09:17:45 CEST 2005


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

Modified Files:
      Tag: release24-maint
	mmapmodule.c 
Log Message:
backport bug [ 728515 ] mmap's resize method resizes the file in win32 but not unix



Index: mmapmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/mmapmodule.c,v
retrieving revision 2.48
retrieving revision 2.48.4.1
diff -u -d -r2.48 -r2.48.4.1
--- mmapmodule.c	19 May 2004 14:39:08 -0000	2.48
+++ mmapmodule.c	24 Aug 2005 07:17:35 -0000	2.48.4.1
@@ -421,6 +421,11 @@
 		return NULL;
 #else
 	} else {
+		if (ftruncate(self->fd, new_size) == -1) {
+			PyErr_SetFromErrno(mmap_module_error);
+			return NULL;
+		}
+		
 		void *newmap;
 
 #ifdef MREMAP_MAYMOVE
@@ -907,7 +912,12 @@
 	if (m_obj == NULL) {return NULL;}
 	m_obj->size = (size_t) map_size;
 	m_obj->pos = (size_t) 0;
-	m_obj->fd = fd;
+	m_obj->fd = dup(fd);
+	if (m_obj->fd == -1) {
+		Py_DECREF(m_obj);
+		PyErr_SetFromErrno(mmap_module_error);
+		return NULL;
+	}
 	m_obj->data = mmap(NULL, map_size, 
 			   prot, flags,
 			   fd, 0);



More information about the Python-checkins mailing list