From 11f6b086db9d98857f761d05707b467c5045ddcc Mon Sep 17 00:00:00 2001 From: John-Mark Gurney Date: Wed, 30 Mar 2022 15:28:07 -0700 Subject: [PATCH] wrap debugpos when at end of buffer.. --- misc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/misc.c b/misc.c index 7f8d6df..64da6de 100644 --- a/misc.c +++ b/misc.c @@ -54,7 +54,7 @@ wait_for_vcp(void) #if MEM_DEBUG_BUF static char debugbuf[1024]; -static uint32_t debugpos; +static uint32_t debugpos = 0; void debug_printf(const char *format, ...) @@ -75,6 +75,9 @@ debug_printf(const char *format, ...) memcpy(&debugbuf[debugpos], pos, cpy); debugpos += cpy; + if (debugpos >= sizeof debugbuf) + debugpos = 0; + pos += cpy; length -= cpy; }