From 34696c0fec5c33ea1c5c48115d14446800d49c02 Mon Sep 17 00:00:00 2001 From: dragonmux Date: Tue, 5 Jul 2022 12:12:18 -0400 Subject: [PATCH] target: Make the buffers used to program a target's Flash better bounded in lifetime and memory usage --- src/target/target.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/target/target.c b/src/target/target.c index 6e8ba24b..0eb0fe3c 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -271,6 +271,11 @@ int target_flash_write(target *t, dest += tmplen; src += tmplen; len -= tmplen; + /* If the current chunk of Flash is now full from this operation + * then finish operations on the Flash chunk and free the internal buffer. + */ + if (dest == f->start + f->length) + ret |= target_flash_done_buffered(f); } return ret; }