From 46c77d3757f8ecc6cf0fdc92dd501c13be195762 Mon Sep 17 00:00:00 2001 From: Andrey Gusakov Date: Sun, 8 Dec 2024 19:26:43 +0300 Subject: [PATCH] logging central: memseting 6500 bytes is waste of time (cherry picked from commit 90bd38d6377e99f7960c319eb6c6df82c6222b18) --- firmware/util/loggingcentral.cpp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/firmware/util/loggingcentral.cpp b/firmware/util/loggingcentral.cpp index 1b79866e46..b0e83ef4aa 100644 --- a/firmware/util/loggingcentral.cpp +++ b/firmware/util/loggingcentral.cpp @@ -47,7 +47,7 @@ size_t LogBuffer::length() const { template void LogBuffer::reset() { m_writePtr = m_buffer; - memset(m_buffer, 0, TBufferSize); + *m_writePtr = '\0'; } template @@ -63,11 +63,10 @@ void LogBuffer::writeInternal(const char* buffer) { // If we can't fit the whole thing, write as much as we can len = minI(available, len); + // Ensure the output buffer is always null terminated (in case we did a partial write) + *(m_writePtr + len) = '\0'; memcpy(m_writePtr, buffer, len); m_writePtr += len; - - // Ensure the output buffer is always null terminated (in case we did a partial write) - *m_writePtr = '\0'; } // for unit tests