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

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


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20685/Modules
Modified Files:
	mmapmodule.c 
Log Message:
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.49
retrieving revision 2.50
diff -u -d -r2.49 -r2.50
--- mmapmodule.c	3 Mar 2005 11:22:44 -0000	2.49
+++ mmapmodule.c	24 Aug 2005 07:17:39 -0000	2.50
@@ -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
@@ -910,7 +915,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

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