Mercurial > cpython-lru_cache-weakref
diff Modules/mmapmodule.c @ 34662:b40586129bb0 legacy-trunk
Patches #749830, #1144555: allow UNIX mmap size to default to current
file size.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Thu, 03 Mar 2005 11:22:44 +0000 |
| parents | 5f4f2f536f96 |
| children | 3bb932801b64 |
line wrap: on
line diff
--- a/Modules/mmapmodule.c Thu Mar 03 11:08:03 2005 +0000 +++ b/Modules/mmapmodule.c Thu Mar 03 11:22:44 2005 +0000 @@ -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);
