Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit ec0a5f0

Browse files
committed
Trimmed trailing whitespace.
1 parent e564e7f commit ec0a5f0

1 file changed

Lines changed: 41 additions & 41 deletions

File tree

Modules/mmapmodule.c

Lines changed: 41 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ mmap_close_method(mmap_object *self, PyObject *args)
122122
return NULL;
123123
#ifdef MS_WINDOWS
124124
/* For each resource we maintain, we need to check
125-
the value is valid, and if so, free the resource
125+
the value is valid, and if so, free the resource
126126
and set the member value to an invalid value so
127127
the dealloc does not attempt to resource clearing
128128
again.
@@ -232,7 +232,7 @@ mmap_read_method(mmap_object *self,
232232
num_bytes -= (self->pos+num_bytes) - self->size;
233233
}
234234
result = Py_BuildValue("s#", self->data+self->pos, num_bytes);
235-
self->pos += num_bytes;
235+
self->pos += num_bytes;
236236
return (result);
237237
}
238238

@@ -272,21 +272,21 @@ mmap_find_method(mmap_object *self,
272272
}
273273
}
274274

275-
static int
275+
static int
276276
is_writeable(mmap_object *self)
277277
{
278278
if (self->access != ACCESS_READ)
279-
return 1;
279+
return 1;
280280
PyErr_Format(PyExc_TypeError, "mmap can't modify a readonly memory map.");
281281
return 0;
282282
}
283283

284-
static int
284+
static int
285285
is_resizeable(mmap_object *self)
286286
{
287287
if ((self->access == ACCESS_WRITE) || (self->access == ACCESS_DEFAULT))
288-
return 1;
289-
PyErr_Format(PyExc_TypeError,
288+
return 1;
289+
PyErr_Format(PyExc_TypeError,
290290
"mmap can't resize a readonly or copy-on-write memory map.");
291291
return 0;
292292
}
@@ -333,7 +333,7 @@ mmap_write_byte_method(mmap_object *self,
333333
Py_INCREF (Py_None);
334334
return (Py_None);
335335
}
336-
336+
337337
static PyObject *
338338
mmap_size_method(mmap_object *self,
339339
PyObject *args)
@@ -379,11 +379,11 @@ mmap_resize_method(mmap_object *self,
379379
{
380380
unsigned long new_size;
381381
CHECK_VALID(NULL);
382-
if (!PyArg_ParseTuple (args, "k:resize", &new_size) ||
382+
if (!PyArg_ParseTuple (args, "k:resize", &new_size) ||
383383
!is_resizeable(self)) {
384384
return NULL;
385385
#ifdef MS_WINDOWS
386-
} else {
386+
} else {
387387
DWORD dwErrCode = 0;
388388
/* First, unmap the file view */
389389
UnmapViewOfFile (self->data);
@@ -423,7 +423,7 @@ mmap_resize_method(mmap_object *self,
423423
#endif /* MS_WINDOWS */
424424

425425
#ifdef UNIX
426-
#ifndef HAVE_MREMAP
426+
#ifndef HAVE_MREMAP
427427
} else {
428428
PyErr_SetString(PyExc_SystemError,
429429
"mmap: resizing not available--no mremap()");
@@ -442,7 +442,7 @@ mmap_resize_method(mmap_object *self,
442442
#else
443443
newmap = mremap(self->data, self->size, new_size, 0);
444444
#endif
445-
if (newmap == (void *)-1)
445+
if (newmap == (void *)-1)
446446
{
447447
PyErr_SetFromErrno(mmap_module_error);
448448
return NULL;
@@ -491,8 +491,8 @@ mmap_flush_method(mmap_object *self, PyObject *args)
491491
PyErr_SetFromErrno(mmap_module_error);
492492
return NULL;
493493
}
494-
return Py_BuildValue ("l", (long) 0);
495-
#endif /* UNIX */
494+
return Py_BuildValue ("l", (long) 0);
495+
#endif /* UNIX */
496496
}
497497
}
498498

@@ -598,7 +598,7 @@ mmap_buffer_getreadbuf(mmap_object *self, Py_ssize_t index, const void **ptr)
598598

599599
static Py_ssize_t
600600
mmap_buffer_getwritebuf(mmap_object *self, Py_ssize_t index, const void **ptr)
601-
{
601+
{
602602
CHECK_VALID(-1);
603603
if ( index != 0 ) {
604604
PyErr_SetString(PyExc_SystemError,
@@ -615,7 +615,7 @@ static Py_ssize_t
615615
mmap_buffer_getsegcount(mmap_object *self, Py_ssize_t *lenp)
616616
{
617617
CHECK_VALID(-1);
618-
if (lenp)
618+
if (lenp)
619619
*lenp = self->size;
620620
return 1;
621621
}
@@ -670,7 +670,7 @@ mmap_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh)
670670
ihigh = ilow;
671671
else if ((size_t)ihigh > self->size)
672672
ihigh = self->size;
673-
673+
674674
return PyString_FromStringAndSize(self->data + ilow, ihigh-ilow);
675675
}
676676

@@ -708,19 +708,19 @@ mmap_ass_slice(mmap_object *self, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v
708708
ihigh = ilow;
709709
else if ((size_t)ihigh > self->size)
710710
ihigh = self->size;
711-
711+
712712
if (v == NULL) {
713713
PyErr_SetString(PyExc_TypeError,
714714
"mmap object doesn't support slice deletion");
715715
return -1;
716716
}
717717
if (! (PyString_Check(v)) ) {
718-
PyErr_SetString(PyExc_IndexError,
718+
PyErr_SetString(PyExc_IndexError,
719719
"mmap slice assignment must be a string");
720720
return -1;
721721
}
722722
if ( PyString_Size(v) != (ihigh - ilow) ) {
723-
PyErr_SetString(PyExc_IndexError,
723+
PyErr_SetString(PyExc_IndexError,
724724
"mmap slice assignment is wrong size");
725725
return -1;
726726
}
@@ -735,7 +735,7 @@ static int
735735
mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v)
736736
{
737737
const char *buf;
738-
738+
739739
CHECK_VALID(-1);
740740
if (i < 0 || (size_t)i >= self->size) {
741741
PyErr_SetString(PyExc_IndexError, "mmap index out of range");
@@ -747,7 +747,7 @@ mmap_ass_item(mmap_object *self, Py_ssize_t i, PyObject *v)
747747
return -1;
748748
}
749749
if (! (PyString_Check(v) && PyString_Size(v)==1) ) {
750-
PyErr_SetString(PyExc_IndexError,
750+
PyErr_SetString(PyExc_IndexError,
751751
"mmap assignment must be single-character string");
752752
return -1;
753753
}
@@ -857,7 +857,7 @@ _GetMapSize(PyObject *o)
857857
return -1;
858858
}
859859

860-
#ifdef UNIX
860+
#ifdef UNIX
861861
static PyObject *
862862
new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
863863
{
@@ -870,21 +870,21 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
870870
int fd, flags = MAP_SHARED, prot = PROT_WRITE | PROT_READ;
871871
int devzero = -1;
872872
int access = (int)ACCESS_DEFAULT;
873-
static const char *keywords[] = {"fileno", "length",
874-
"flags", "prot",
873+
static const char *keywords[] = {"fileno", "length",
874+
"flags", "prot",
875875
"access", NULL};
876876

877-
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords,
877+
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|iii", keywords,
878878
&fd, &map_size_obj, &flags, &prot,
879879
&access))
880880
return NULL;
881881
map_size = _GetMapSize(map_size_obj);
882882
if (map_size < 0)
883883
return NULL;
884884

885-
if ((access != (int)ACCESS_DEFAULT) &&
885+
if ((access != (int)ACCESS_DEFAULT) &&
886886
((flags != MAP_SHARED) || (prot != (PROT_WRITE | PROT_READ))))
887-
return PyErr_Format(PyExc_ValueError,
887+
return PyErr_Format(PyExc_ValueError,
888888
"mmap can't specify both access and flags, prot.");
889889
switch ((access_mode)access) {
890890
case ACCESS_READ:
@@ -899,11 +899,11 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
899899
flags = MAP_PRIVATE;
900900
prot = PROT_READ | PROT_WRITE;
901901
break;
902-
case ACCESS_DEFAULT:
902+
case ACCESS_DEFAULT:
903903
/* use the specified or default values of flags and prot */
904904
break;
905905
default:
906-
return PyErr_Format(PyExc_ValueError,
906+
return PyErr_Format(PyExc_ValueError,
907907
"mmap invalid access parameter.");
908908
}
909909

@@ -916,7 +916,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
916916
if (map_size == 0) {
917917
map_size = (int)st.st_size;
918918
} else if ((size_t)map_size > st.st_size) {
919-
PyErr_SetString(PyExc_ValueError,
919+
PyErr_SetString(PyExc_ValueError,
920920
"mmap length is greater than file size");
921921
return NULL;
922922
}
@@ -954,7 +954,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
954954
}
955955
}
956956

957-
m_obj->data = mmap(NULL, map_size,
957+
m_obj->data = mmap(NULL, map_size,
958958
prot, flags,
959959
fd, 0);
960960

@@ -988,12 +988,12 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
988988
HANDLE fh = 0;
989989
int access = (access_mode)ACCESS_DEFAULT;
990990
DWORD flProtect, dwDesiredAccess;
991-
static const char *keywords[] = { "fileno", "length",
992-
"tagname",
991+
static const char *keywords[] = { "fileno", "length",
992+
"tagname",
993993
"access", NULL };
994994

995995
if (!PyArg_ParseTupleAndKeywords(args, kwdict, "iO|zi", keywords,
996-
&fileno, &map_size_obj,
996+
&fileno, &map_size_obj,
997997
&tagname, &access)) {
998998
return NULL;
999999
}
@@ -1012,14 +1012,14 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
10121012
dwDesiredAccess = FILE_MAP_COPY;
10131013
break;
10141014
default:
1015-
return PyErr_Format(PyExc_ValueError,
1015+
return PyErr_Format(PyExc_ValueError,
10161016
"mmap invalid access parameter.");
10171017
}
10181018

10191019
map_size = _GetMapSize(map_size_obj);
10201020
if (map_size < 0)
10211021
return NULL;
1022-
1022+
10231023
/* assume -1 and 0 both mean invalid filedescriptor
10241024
to 'anonymously' map memory.
10251025
XXX: fileno == 0 is a valid fd, but was accepted prior to 2.5.
@@ -1131,7 +1131,7 @@ new_mmap_object(PyObject *self, PyObject *args, PyObject *kwdict)
11311131

11321132
/* List of functions exported by this module */
11331133
static struct PyMethodDef mmap_functions[] = {
1134-
{"mmap", (PyCFunction) new_mmap_object,
1134+
{"mmap", (PyCFunction) new_mmap_object,
11351135
METH_VARARGS|METH_KEYWORDS},
11361136
{NULL, NULL} /* Sentinel */
11371137
};
@@ -1185,10 +1185,10 @@ PyMODINIT_FUNC
11851185
PyDict_SetItemString (dict, "PAGESIZE",
11861186
PyInt_FromLong( (long)my_getpagesize() ) );
11871187

1188-
PyDict_SetItemString (dict, "ACCESS_READ",
1188+
PyDict_SetItemString (dict, "ACCESS_READ",
11891189
PyInt_FromLong(ACCESS_READ));
1190-
PyDict_SetItemString (dict, "ACCESS_WRITE",
1190+
PyDict_SetItemString (dict, "ACCESS_WRITE",
11911191
PyInt_FromLong(ACCESS_WRITE));
1192-
PyDict_SetItemString (dict, "ACCESS_COPY",
1192+
PyDict_SetItemString (dict, "ACCESS_COPY",
11931193
PyInt_FromLong(ACCESS_COPY));
11941194
}

0 commit comments

Comments
 (0)