aboutsummaryrefslogtreecommitdiff
path: root/py/modio.c
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-03-25 14:59:30 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-03-25 14:59:30 +0200
commit2c81b9be28dccf973b7c3a7d791ba79ebad6b206 (patch)
tree5e3c8ddc6c0c64b82087eedc1fd311009dbbbc84 /py/modio.c
parent063e6e7d0aa6fa6ad9f9c65cac4eb49e4a5a6548 (diff)
py/modio: io.BufferedWriter: Describe flushing policy.
Diffstat (limited to 'py/modio.c')
-rw-r--r--py/modio.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/py/modio.c b/py/modio.c
index d41e9592b..96805d291 100644
--- a/py/modio.c
+++ b/py/modio.c
@@ -69,6 +69,12 @@ STATIC mp_uint_t bufwriter_write(mp_obj_t self_in, const void *buf, mp_uint_t si
return org_size;
}
+ // Buffer flushing policy here is to flush entire buffer all the time.
+ // This allows e.g. to have a block device as backing storage and write
+ // entire block to it. memcpy below is not ideal and could be optimized
+ // in some cases. But the way it is now it at least ensures that buffer
+ // is word-aligned, to guard against obscure cases when it matters, e.g.
+ // https://github.com/micropython/micropython/issues/1863
memcpy(self->buf + self->len, buf, rem);
buf = (byte*)buf + rem;
size -= rem;