Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
38387b8b
Commit
38387b8b
authored
Aug 24, 2005
by
Georg Brandl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug [ 728515 ] mmap's resize method resizes the file in win32 but not unix
parent
76fb6d84
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
1 deletion
+23
-1
Doc/lib/libmmap.tex
Doc/lib/libmmap.tex
+1
-0
Lib/test/test_mmap.py
Lib/test/test_mmap.py
+8
-0
Misc/NEWS
Misc/NEWS
+3
-0
Modules/mmapmodule.c
Modules/mmapmodule.c
+11
-1
No files found.
Doc/lib/libmmap.tex
View file @
38387b8b
...
...
@@ -132,6 +132,7 @@ Memory-mapped file objects support the following methods:
\end{methoddesc}
\begin{methoddesc}
{
resize
}{
\var
{
newsize
}}
Resizes the map and the underlying file, if any.
If the mmap was created with
\constant
{
ACCESS
_
READ
}
or
\constant
{
ACCESS
_
COPY
}
, resizing the map will throw a
\exception
{
TypeError
}
exception.
\end{methoddesc}
...
...
Lib/test/test_mmap.py
View file @
38387b8b
...
...
@@ -120,6 +120,14 @@ def test_both():
else
:
verify
(
0
,
'Could seek beyond the new size'
)
# Check that the underlying file is truncated too
# (bug #728515)
f
=
open
(
TESTFN
)
f
.
seek
(
0
,
2
)
verify
(
f
.
tell
()
==
512
,
'Underlying file not truncated'
)
f
.
close
()
verify
(
m
.
size
()
==
512
,
'New size not reflected in file'
)
m
.
close
()
finally
:
...
...
Misc/NEWS
View file @
38387b8b
...
...
@@ -128,6 +128,9 @@ Core and builtins
Extension Modules
-----------------
- Bug #728515: mmap.resize() now resizes the file on Unix as it did
on Windows.
- Patch #1180695: Add nanosecond stat resolution, and st_gen,
st_birthtime for FreeBSD.
...
...
Modules/mmapmodule.c
View file @
38387b8b
...
...
@@ -421,6 +421,11 @@ mmap_resize_method(mmap_object *self,
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 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
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
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment