From 1e6d843e6574363d7fc6b131168a3aadbe330033 Mon Sep 17 00:00:00 2001 From: Song Ruo Jing Date: Mon, 26 Aug 2024 15:40:29 +0800 Subject: [PATCH] fix(ringbuf): allow xRingbufferCreateWithCaps to pass in non-32-bit aligned size --- components/esp_ringbuf/ringbuf.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/esp_ringbuf/ringbuf.c b/components/esp_ringbuf/ringbuf.c index aa877f38d2..31ef6227ab 100644 --- a/components/esp_ringbuf/ringbuf.c +++ b/components/esp_ringbuf/ringbuf.c @@ -1374,6 +1374,11 @@ RingbufHandle_t xRingbufferCreateWithCaps(size_t xBufferSize, RingbufferType_t x StaticRingbuffer_t *pxStaticRingbuffer; uint8_t *pucRingbufferStorage; + //Allocate memory + if (xBufferType != RINGBUF_TYPE_BYTEBUF) { + xBufferSize = rbALIGN_SIZE(xBufferSize); //xBufferSize is rounded up for no-split/allow-split buffers + } + pxStaticRingbuffer = heap_caps_malloc(sizeof(StaticRingbuffer_t), (uint32_t)uxMemoryCaps); pucRingbufferStorage = heap_caps_malloc(xBufferSize, (uint32_t)uxMemoryCaps);