[core] Ring buffer write functions use const pointer parameter (#7750)

This commit is contained in:
Kevin Ahrendt 2024-11-12 13:48:03 -05:00 committed by GitHub
parent e6a1254e65
commit b367c01b4b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View file

@ -46,7 +46,7 @@ size_t RingBuffer::read(void *data, size_t len, TickType_t ticks_to_wait) {
return bytes_read; return bytes_read;
} }
size_t RingBuffer::write(void *data, size_t len) { size_t RingBuffer::write(const void *data, size_t len) {
size_t free = this->free(); size_t free = this->free();
if (free < len) { if (free < len) {
size_t needed = len - free; size_t needed = len - free;
@ -56,7 +56,7 @@ size_t RingBuffer::write(void *data, size_t len) {
return xStreamBufferSend(this->handle_, data, len, 0); return xStreamBufferSend(this->handle_, data, len, 0);
} }
size_t RingBuffer::write_without_replacement(void *data, size_t len, TickType_t ticks_to_wait) { size_t RingBuffer::write_without_replacement(const void *data, size_t len, TickType_t ticks_to_wait) {
return xStreamBufferSend(this->handle_, data, len, ticks_to_wait); return xStreamBufferSend(this->handle_, data, len, ticks_to_wait);
} }

View file

@ -37,7 +37,7 @@ class RingBuffer {
* @param len Number of bytes to write * @param len Number of bytes to write
* @return Number of bytes written * @return Number of bytes written
*/ */
size_t write(void *data, size_t len); size_t write(const void *data, size_t len);
/** /**
* @brief Writes to the ring buffer without overwriting oldest data. * @brief Writes to the ring buffer without overwriting oldest data.
@ -50,7 +50,7 @@ class RingBuffer {
* @param ticks_to_wait Maximum number of FreeRTOS ticks to wait (default: 0) * @param ticks_to_wait Maximum number of FreeRTOS ticks to wait (default: 0)
* @return Number of bytes written * @return Number of bytes written
*/ */
size_t write_without_replacement(void *data, size_t len, TickType_t ticks_to_wait = 0); size_t write_without_replacement(const void *data, size_t len, TickType_t ticks_to_wait = 0);
/** /**
* @brief Returns the number of available bytes in the ring buffer. * @brief Returns the number of available bytes in the ring buffer.