Skip to content

Commit

Permalink
logging central: memseting 6500 bytes is waste of time
Browse files Browse the repository at this point in the history
(cherry picked from commit 90bd38d6377e99f7960c319eb6c6df82c6222b18)
  • Loading branch information
dron0gus authored and rusefillc committed Dec 9, 2024
1 parent 6cef91b commit 46c77d3
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions firmware/util/loggingcentral.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ size_t LogBuffer<TBufferSize>::length() const {
template <size_t TBufferSize>
void LogBuffer<TBufferSize>::reset() {
m_writePtr = m_buffer;
memset(m_buffer, 0, TBufferSize);
*m_writePtr = '\0';
}

template <size_t TBufferSize>
Expand All @@ -63,11 +63,10 @@ void LogBuffer<TBufferSize>::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
Expand Down

0 comments on commit 46c77d3

Please sign in to comment.