mirror of
https://github.com/espressif/esp-idf.git
synced 2025-08-07 20:00:53 +00:00
fix(ringbuf): xRingbufferReceive() crashes for allow-split buffers
This commit adds an assert check to xRingbufferReceive() and xRingbufferReceiveFromISR() functions to prevent them from being used to retrieve items from an allow-split buffer. Corresponding documentation has also been updated.
This commit is contained in:
@@ -296,6 +296,10 @@ Byte buffers **do not allow multiple retrievals before returning** (every retrie
|
||||
|
||||
Referring to the diagram above, the 38 bytes of continuous stored data at the tail of the buffer is retrieved, returned, and freed. The next call to :cpp:func:`xRingbufferReceive` or :cpp:func:`xRingbufferReceiveFromISR` then wraps around and does the same to the 30 bytes of continuous stored data at the head of the buffer.
|
||||
|
||||
.. note::
|
||||
|
||||
Retrieving items from Allow-Split buffers must be done via :cpp:func:`xRingbufferReceiveSplit` or :cpp:func:`xRingbufferReceiveSplitFromISR` instead of :cpp:func:`xRingbufferReceive` or :cpp:func:`xRingbufferReceiveFromISR`.
|
||||
|
||||
Ring Buffers with Queue Sets
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
@@ -296,6 +296,10 @@ ESP-IDF 环形 buffer 是一个典型的 FIFO buffer,支持任意大小的数
|
||||
|
||||
参考上图, buffer 尾部 38 字节连续存储的数据被检索、返回和释放。然后,下一次调用 :cpp:func:`xRingbufferReceive` 或 :cpp:func:`xRingbufferReceiveFromISR` 时,buffer 将绕回并对头部的 30 字节连续存储数据进行同样的处理。
|
||||
|
||||
.. note::
|
||||
|
||||
从可分割 buffer 中检索数据项必须使用 :cpp:func:`xRingbufferReceiveSplit` 或 :cpp:func:`xRingbufferReceiveSplitFromISR`,而不是 :cpp:func:`xRingbufferReceive` 或 :cpp:func:`xRingbufferReceiveFromISR`。
|
||||
|
||||
使用队列集的环形 buffer
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
|
Reference in New Issue
Block a user