Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(69951)

Side by Side Diff: Modules/mmapmodule.c

Issue 26335: Make mmap.write return the number of bytes written like other write methods
Patch Set: Created 3 years, 4 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« Lib/test/test_mmap.py ('K') | « Lib/test/test_mmap.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 / Author: Sam Rushing <rushing@nightmare.com> 2 / Author: Sam Rushing <rushing@nightmare.com>
3 / Hacked for Unix by AMK 3 / Hacked for Unix by AMK
4 / $Id$ 4 / $Id$
5 5
6 / Modified to support mmap with offset - to map a 'window' of a file 6 / Modified to support mmap with offset - to map a 'window' of a file
7 / Author: Yotam Medini yotamm@mellanox.co.il 7 / Author: Yotam Medini yotamm@mellanox.co.il
8 / 8 /
9 / mmapmodule.cpp -- map a view of a file into memory 9 / mmapmodule.cpp -- map a view of a file into memory
10 / 10 /
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 } 400 }
401 401
402 if ((self->pos + data.len) > self->size) { 402 if ((self->pos + data.len) > self->size) {
403 PyErr_SetString(PyExc_ValueError, "data out of range"); 403 PyErr_SetString(PyExc_ValueError, "data out of range");
404 PyBuffer_Release(&data); 404 PyBuffer_Release(&data);
405 return NULL; 405 return NULL;
406 } 406 }
407 memcpy(self->data + self->pos, data.buf, data.len); 407 memcpy(self->data + self->pos, data.buf, data.len);
408 self->pos = self->pos + data.len; 408 self->pos = self->pos + data.len;
409 PyBuffer_Release(&data); 409 PyBuffer_Release(&data);
410 Py_INCREF(Py_None); 410 Py_INCREF(Py_None);
berkerpeksag 2016/02/23 00:57:52 This can be removed now.
411 return Py_None; 411 return PyLong_FromSsize_t(data.len);
berkerpeksag 2016/02/23 00:57:52 We need to save the value of ``data.len`` before t
412 } 412 }
413 413
414 static PyObject * 414 static PyObject *
415 mmap_write_byte_method(mmap_object *self, 415 mmap_write_byte_method(mmap_object *self,
416 PyObject *args) 416 PyObject *args)
417 { 417 {
418 char value; 418 char value;
419 419
420 CHECK_VALID(NULL); 420 CHECK_VALID(NULL);
421 if (!PyArg_ParseTuple(args, "b:write_byte", &value)) 421 if (!PyArg_ParseTuple(args, "b:write_byte", &value))
(...skipping 1105 matching lines...) Expand 10 before | Expand all | Expand 10 after
1527 1527
1528 setint(dict, "PAGESIZE", (long)my_getpagesize()); 1528 setint(dict, "PAGESIZE", (long)my_getpagesize());
1529 1529
1530 setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity()); 1530 setint(dict, "ALLOCATIONGRANULARITY", (long)my_getallocationgranularity());
1531 1531
1532 setint(dict, "ACCESS_READ", ACCESS_READ); 1532 setint(dict, "ACCESS_READ", ACCESS_READ);
1533 setint(dict, "ACCESS_WRITE", ACCESS_WRITE); 1533 setint(dict, "ACCESS_WRITE", ACCESS_WRITE);
1534 setint(dict, "ACCESS_COPY", ACCESS_COPY); 1534 setint(dict, "ACCESS_COPY", ACCESS_COPY);
1535 return module; 1535 return module;
1536 } 1536 }
OLDNEW
« Lib/test/test_mmap.py ('K') | « Lib/test/test_mmap.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+