xMessageBufferCreate() API – Meaning of xBufferSizeBytes

The xBufferSizeBytes parameter of the xMessageBufferCreate() needs to be manually increased by sizeof(size_t). Is there a good technical reason why this increment is not done internally? E.g. inside xStreamBufferGenericCreate() we have an assert to check the buffer size: ~~~ if( xIsMessageBuffer == pdTRUE ) { /* Is a message buffer but not statically allocated. / ucFlags = sbFLAGS_IS_MESSAGE_BUFFER; configASSERT( xBufferSizeBytes > sbBYTES_TO_STORE_MESSAGE_LENGTH ); } ~~~ when we could simply increment the size: ~~~ if( xIsMessageBuffer == pdTRUE ) { / Is a message buffer but not statically allocated. */ ucFlags = sbFLAGS_IS_MESSAGE_BUFFER; xBufferSizeBytes += sbBYTES_TO_STORE_MESSAGE_LENGTH; } ~~~

xMessageBufferCreate() API – Meaning of xBufferSizeBytes

The way the parameter works is described on the API function’s documentation page: https://www.freertos.org/xMessageBufferCreate.html The user needs to know how it works as, for example, if you wanted to store two messages, just adding one additional lot of sbBYTESTOSTOREMESSAGELENGTH bytes is not going to help (as two lots would be needed), and possible just confuse. It is considered best to let the application writer define the buffer’s size explicitly.

xMessageBufferCreate() API – Meaning of xBufferSizeBytes

Thank you for the answer. I had missed the fact that you can store multiple messages in the buffer.