summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--py/modio.c6
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;