From 30e2106e406c9dba9a94b0c05a620a548b696c71 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 b877825..1ff7ca6 100644 --- a/src/target/target.c +++ b/src/target/target.c @@ -283,6 +283,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; }