Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
cfe7e091
Kaydet (Commit)
cfe7e091
authored
Şub 17, 2006
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Remove size restrictions.
üst
f2882957
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
29 deletions
+19
-29
mmapmodule.c
Modules/mmapmodule.c
+19
-29
No files found.
Modules/mmapmodule.c
Dosyayı görüntüle @
cfe7e091
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
/ ftp://squirl.nightmare.com/pub/python/python-ext.
/ ftp://squirl.nightmare.com/pub/python/python-ext.
*/
*/
#define PY_SSIZE_T_CLEAN
#include <Python.h>
#include <Python.h>
#ifndef MS_WINDOWS
#ifndef MS_WINDOWS
...
@@ -242,7 +243,7 @@ mmap_find_method(mmap_object *self,
...
@@ -242,7 +243,7 @@ mmap_find_method(mmap_object *self,
{
{
Py_ssize_t
start
=
self
->
pos
;
Py_ssize_t
start
=
self
->
pos
;
char
*
needle
;
char
*
needle
;
in
t
len
;
Py_ssize_
t
len
;
CHECK_VALID
(
NULL
);
CHECK_VALID
(
NULL
);
if
(
!
PyArg_ParseTuple
(
args
,
"s#|n:find"
,
&
needle
,
&
len
,
&
start
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"s#|n:find"
,
&
needle
,
&
len
,
&
start
))
{
...
@@ -259,16 +260,14 @@ mmap_find_method(mmap_object *self,
...
@@ -259,16 +260,14 @@ mmap_find_method(mmap_object *self,
start
=
self
->
size
;
start
=
self
->
size
;
for
(
p
=
self
->
data
+
start
;
p
+
len
<=
e
;
++
p
)
{
for
(
p
=
self
->
data
+
start
;
p
+
len
<=
e
;
++
p
)
{
in
t
i
;
Py_ssize_
t
i
;
for
(
i
=
0
;
i
<
len
&&
needle
[
i
]
==
p
[
i
];
++
i
)
for
(
i
=
0
;
i
<
len
&&
needle
[
i
]
==
p
[
i
];
++
i
)
/* nothing */
;
/* nothing */
;
if
(
i
==
len
)
{
if
(
i
==
len
)
{
return
Py_BuildValue
(
return
PyInt_FromSsize_t
(
p
-
self
->
data
);
"l"
,
(
long
)
(
p
-
self
->
data
));
}
}
}
}
return
Py
_BuildValue
(
"l"
,
(
long
)
-
1
);
return
Py
Int_FromLong
(
-
1
);
}
}
}
}
...
@@ -296,7 +295,7 @@ static PyObject *
...
@@ -296,7 +295,7 @@ static PyObject *
mmap_write_method
(
mmap_object
*
self
,
mmap_write_method
(
mmap_object
*
self
,
PyObject
*
args
)
PyObject
*
args
)
{
{
in
t
length
;
Py_ssize_
t
length
;
char
*
data
;
char
*
data
;
CHECK_VALID
(
NULL
);
CHECK_VALID
(
NULL
);
...
@@ -377,9 +376,9 @@ static PyObject *
...
@@ -377,9 +376,9 @@ static PyObject *
mmap_resize_method
(
mmap_object
*
self
,
mmap_resize_method
(
mmap_object
*
self
,
PyObject
*
args
)
PyObject
*
args
)
{
{
unsigned
long
new_size
;
Py_ssize_t
new_size
;
CHECK_VALID
(
NULL
);
CHECK_VALID
(
NULL
);
if
(
!
PyArg_ParseTuple
(
args
,
"
k
:resize"
,
&
new_size
)
||
if
(
!
PyArg_ParseTuple
(
args
,
"
n
:resize"
,
&
new_size
)
||
!
is_resizeable
(
self
))
{
!
is_resizeable
(
self
))
{
return
NULL
;
return
NULL
;
#ifdef MS_WINDOWS
#ifdef MS_WINDOWS
...
@@ -498,10 +497,10 @@ mmap_flush_method(mmap_object *self, PyObject *args)
...
@@ -498,10 +497,10 @@ mmap_flush_method(mmap_object *self, PyObject *args)
static
PyObject
*
static
PyObject
*
mmap_seek_method
(
mmap_object
*
self
,
PyObject
*
args
)
mmap_seek_method
(
mmap_object
*
self
,
PyObject
*
args
)
{
{
in
t
dist
;
Py_ssize_
t
dist
;
int
how
=
0
;
int
how
=
0
;
CHECK_VALID
(
NULL
);
CHECK_VALID
(
NULL
);
if
(
!
PyArg_ParseTuple
(
args
,
"
i
|i:seek"
,
&
dist
,
&
how
))
if
(
!
PyArg_ParseTuple
(
args
,
"
n
|i:seek"
,
&
dist
,
&
how
))
return
NULL
;
return
NULL
;
else
{
else
{
size_t
where
;
size_t
where
;
...
@@ -512,12 +511,12 @@ mmap_seek_method(mmap_object *self, PyObject *args)
...
@@ -512,12 +511,12 @@ mmap_seek_method(mmap_object *self, PyObject *args)
where
=
dist
;
where
=
dist
;
break
;
break
;
case
1
:
/* relative to current position */
case
1
:
/* relative to current position */
if
((
in
t
)
self
->
pos
+
dist
<
0
)
if
((
Py_ssize_
t
)
self
->
pos
+
dist
<
0
)
goto
onoutofrange
;
goto
onoutofrange
;
where
=
self
->
pos
+
dist
;
where
=
self
->
pos
+
dist
;
break
;
break
;
case
2
:
/* relative to end */
case
2
:
/* relative to end */
if
((
in
t
)
self
->
size
+
dist
<
0
)
if
((
Py_ssize_
t
)
self
->
size
+
dist
<
0
)
goto
onoutofrange
;
goto
onoutofrange
;
where
=
self
->
size
+
dist
;
where
=
self
->
size
+
dist
;
break
;
break
;
...
@@ -802,14 +801,9 @@ static PyTypeObject mmap_object_type = {
...
@@ -802,14 +801,9 @@ static PyTypeObject mmap_object_type = {
/* extract the map size from the given PyObject
/* extract the map size from the given PyObject
The map size is restricted to [0, INT_MAX] because this is the current
Python limitation on object sizes. Although the mmap object *could* handle
a larger map size, there is no point because all the useful operations
(len(), slicing(), sequence indexing) are limited by a C int.
Returns -1 on error, with an appropriate Python exception raised. On
Returns -1 on error, with an appropriate Python exception raised. On
success, the map size is returned. */
success, the map size is returned. */
static
in
t
static
Py_ssize_
t
_GetMapSize
(
PyObject
*
o
)
_GetMapSize
(
PyObject
*
o
)
{
{
if
(
PyInt_Check
(
o
))
{
if
(
PyInt_Check
(
o
))
{
...
@@ -818,12 +812,10 @@ _GetMapSize(PyObject *o)
...
@@ -818,12 +812,10 @@ _GetMapSize(PyObject *o)
return
-
1
;
return
-
1
;
if
(
i
<
0
)
if
(
i
<
0
)
goto
onnegoverflow
;
goto
onnegoverflow
;
if
(
i
>
INT_MAX
)
return
i
;
goto
onposoverflow
;
return
(
int
)
i
;
}
}
else
if
(
PyLong_Check
(
o
))
{
else
if
(
PyLong_Check
(
o
))
{
long
i
=
PyLong_AsLong
(
o
);
Py_ssize_t
i
=
PyInt_AsSsize_t
(
o
);
if
(
PyErr_Occurred
())
{
if
(
PyErr_Occurred
())
{
/* yes negative overflow is mistaken for positive overflow
/* yes negative overflow is mistaken for positive overflow
but not worth the trouble to check sign of 'i' */
but not worth the trouble to check sign of 'i' */
...
@@ -834,9 +826,7 @@ _GetMapSize(PyObject *o)
...
@@ -834,9 +826,7 @@ _GetMapSize(PyObject *o)
}
}
if
(
i
<
0
)
if
(
i
<
0
)
goto
onnegoverflow
;
goto
onnegoverflow
;
if
(
i
>
INT_MAX
)
return
i
;
goto
onposoverflow
;
return
(
int
)
i
;
}
}
else
{
else
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
...
@@ -864,7 +854,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
...
@@ -864,7 +854,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
#endif
#endif
mmap_object
*
m_obj
;
mmap_object
*
m_obj
;
PyObject
*
map_size_obj
=
NULL
;
PyObject
*
map_size_obj
=
NULL
;
in
t
map_size
;
Py_ssize_
t
map_size
;
int
fd
,
flags
=
MAP_SHARED
,
prot
=
PROT_WRITE
|
PROT_READ
;
int
fd
,
flags
=
MAP_SHARED
,
prot
=
PROT_WRITE
|
PROT_READ
;
int
devzero
=
-
1
;
int
devzero
=
-
1
;
int
access
=
(
int
)
ACCESS_DEFAULT
;
int
access
=
(
int
)
ACCESS_DEFAULT
;
...
@@ -912,7 +902,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
...
@@ -912,7 +902,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
# endif
# endif
if
(
fstat
(
fd
,
&
st
)
==
0
&&
S_ISREG
(
st
.
st_mode
))
{
if
(
fstat
(
fd
,
&
st
)
==
0
&&
S_ISREG
(
st
.
st_mode
))
{
if
(
map_size
==
0
)
{
if
(
map_size
==
0
)
{
map_size
=
(
int
)
st
.
st_size
;
map_size
=
st
.
st_size
;
}
else
if
((
size_t
)
map_size
>
st
.
st_size
)
{
}
else
if
((
size_t
)
map_size
>
st
.
st_size
)
{
PyErr_SetString
(
PyExc_ValueError
,
PyErr_SetString
(
PyExc_ValueError
,
"mmap length is greater than file size"
);
"mmap length is greater than file size"
);
...
@@ -977,7 +967,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
...
@@ -977,7 +967,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
{
{
mmap_object
*
m_obj
;
mmap_object
*
m_obj
;
PyObject
*
map_size_obj
=
NULL
;
PyObject
*
map_size_obj
=
NULL
;
in
t
map_size
;
Py_ssize_
t
map_size
;
DWORD
size_hi
;
/* upper 32 bits of m_obj->size */
DWORD
size_hi
;
/* upper 32 bits of m_obj->size */
DWORD
size_lo
;
/* lower 32 bits of m_obj->size */
DWORD
size_lo
;
/* lower 32 bits of m_obj->size */
char
*
tagname
=
""
;
char
*
tagname
=
""
;
...
...
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