#define mbMESSAGE_BUFFER_LENGTH_BYTES ( ( size_t ) 50 )\r
\r
/* The number of additional bytes used to store the length of each message. */\r
-#define mbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( size_t ) )\r
+#define mbBYTES_TO_STORE_MESSAGE_LENGTH ( sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) )\r
\r
/* Start and end ASCII characters used in messages sent to the buffers. */\r
#define mbASCII_SPACE 32\r
additional 4 bytes are added to hold the item's size. That means adding\r
6 bytes to the buffer will actually add 10 bytes to the buffer. Therefore,\r
with a 50 byte buffer, a maximum of 5 6 bytes items can be added before the\r
- buffer is completely full. */\r
+ buffer is completely full. NOTE: The numbers in this paragraph assume\r
+ sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) == 4. */\r
for( xItem = 0; xItem < xMax6ByteMessages; xItem++ )\r
{\r
configASSERT( xMessageBufferIsFull( xMessageBuffer ) == pdFALSE );\r
xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES, mbDONT_BLOCK );\r
configASSERT( xReturned == 0 );\r
( void ) xReturned; /* In case configASSERT() is not defined. */\r
- xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 1, mbDONT_BLOCK );\r
- configASSERT( xReturned == 0 );\r
- ( void ) xReturned; /* In case configASSERT() is not defined. */\r
- xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 2, mbDONT_BLOCK );\r
- configASSERT( xReturned == 0 );\r
- ( void ) xReturned; /* In case configASSERT() is not defined. */\r
- xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 3, mbDONT_BLOCK );\r
- configASSERT( xReturned == 0 );\r
- ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+ #ifndef configMESSAGE_BUFFER_LENGTH_TYPE\r
+ {\r
+ /* The following will fail if configMESSAGE_BUFFER_LENGTH_TYPE is set\r
+ to a non 32-bit type. */\r
+ xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 1, mbDONT_BLOCK );\r
+ configASSERT( xReturned == 0 );\r
+ ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+ xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 2, mbDONT_BLOCK );\r
+ configASSERT( xReturned == 0 );\r
+ ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+ xReturned = xMessageBufferSend( xMessageBuffer, ( const void * ) pc55ByteString, mbMESSAGE_BUFFER_LENGTH_BYTES - 3, mbDONT_BLOCK );\r
+ configASSERT( xReturned == 0 );\r
+ ( void ) xReturned; /* In case configASSERT() is not defined. */\r
+ }\r
+ #endif\r
\r
/* Don't expect any messages to be available as the above were too large to\r
get written. */\r
{\r
StreamBuffer_t * const pxStreamBuffer = ( StreamBuffer_t * ) xStreamBuffer; /*lint !e9087 !e9079 Safe cast as StreamBufferHandle_t is opaque Streambuffer_t. */\r
size_t xReturn, xBytesAvailable, xOriginalTail;\r
+configMESSAGE_BUFFER_LENGTH_TYPE xTempReturn;\r
\r
configASSERT( pxStreamBuffer );\r
\r
returned to its prior state as the message is not actually being\r
removed from the buffer. */\r
xOriginalTail = pxStreamBuffer->xTail;\r
- ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable );\r
+ ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempReturn, sbBYTES_TO_STORE_MESSAGE_LENGTH, xBytesAvailable );\r
+ xReturn = ( size_t ) xTempReturn;\r
pxStreamBuffer->xTail = xOriginalTail;\r
}\r
else\r
size_t xBytesToStoreMessageLength )\r
{\r
size_t xOriginalTail, xReceivedLength, xNextMessageLength;\r
+configMESSAGE_BUFFER_LENGTH_TYPE xTempNextMessageLength;\r
\r
if( xBytesToStoreMessageLength != ( size_t ) 0 )\r
{\r
returned to its prior state if the length of the message is too\r
large for the provided buffer. */\r
xOriginalTail = pxStreamBuffer->xTail;\r
- /* Ensure xNextMessageLength is cleared to 0 in case\r
- sizeof( configMESSAGE_BUFFER_LENGTH_TYPE ) != sizeof( size_t ). */\r
- xNextMessageLength = 0;\r
- ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );\r
+ ( void ) prvReadBytesFromBuffer( pxStreamBuffer, ( uint8_t * ) &xTempNextMessageLength, xBytesToStoreMessageLength, xBytesAvailable );\r
+ xNextMessageLength = ( size_t ) xTempNextMessageLength;\r
\r
/* Reduce the number of bytes available by the number of bytes just\r
read out. */\r