diff options
author | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-03-25 14:59:30 +0200 |
---|---|---|
committer | Paul Sokolovsky <pfalcon@users.sourceforge.net> | 2016-03-25 14:59:30 +0200 |
commit | 2c81b9be28dccf973b7c3a7d791ba79ebad6b206 (patch) | |
tree | 5e3c8ddc6c0c64b82087eedc1fd311009dbbbc84 | |
parent | 063e6e7d0aa6fa6ad9f9c65cac4eb49e4a5a6548 (diff) | |
download | micropython-2c81b9be28dccf973b7c3a7d791ba79ebad6b206.tar.gz micropython-2c81b9be28dccf973b7c3a7d791ba79ebad6b206.zip |
py/modio: io.BufferedWriter: Describe flushing policy.
-rw-r--r-- | py/modio.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/py/modio.c b/py/modio.c index d41e9592bf..96805d2911 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; |