From 6da879af6531e5bdf846254594eebc40708a55b5 Mon Sep 17 00:00:00 2001 From: Diego Ferigo Date: Fri, 6 Apr 2018 13:35:58 +0200 Subject: [PATCH] Fixed wrong buffer substitution in Signal class With the CONTIGUOUS_ZEROCOPY signal data format, since the memory is not owned by the Signal object it should not be modified. Changing the buffer in this case means only updating the pointer to the first element and the signal width. --- toolbox/src/base/Signal.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/toolbox/src/base/Signal.cpp b/toolbox/src/base/Signal.cpp index 2f1abad62..906252d2a 100644 --- a/toolbox/src/base/Signal.cpp +++ b/toolbox/src/base/Signal.cpp @@ -320,10 +320,8 @@ bool Signal::setBuffer(const T* data, const unsigned& length) std::copy(data, data + length, getBuffer()); break; case DataFormat::CONTIGUOUS_ZEROCOPY: - // Reset current data - std::fill(getBuffer(), getBuffer() + m_width, 0); - // Copy new data - std::copy(data, data + length, getBuffer()); + // Override the buffer pointer + m_bufferPtr = static_cast(const_cast(data)); // Update the width m_width = length; break;