diff options
Diffstat (limited to 'FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c')
-rw-r--r-- | FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c index 855c9cbd3..5501da30a 100644 --- a/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c +++ b/FreeRTOS-Plus/Source/FreeRTOS-Plus-TCP/FreeRTOS_Stream_Buffer.c @@ -44,9 +44,10 @@ * will be used when TCP data is received while earlier data is still missing. * If 'pucData' equals NULL, the function is called to advance 'uxHead' only. */ -size_t uxStreamBufferAdd( StreamBuffer_t *pxBuffer, size_t uxOffset, const uint8_t *pucData, size_t uxCount ) +size_t uxStreamBufferAdd( StreamBuffer_t *pxBuffer, size_t uxOffset, const uint8_t *pucData, size_t uxByteCount ) { size_t uxSpace, uxNextHead, uxFirst; +size_t uxCount = uxByteCount; uxSpace = uxStreamBufferGetSpace( pxBuffer ); @@ -57,18 +58,18 @@ size_t uxSpace, uxNextHead, uxFirst; } else { - uxSpace = 0u; + uxSpace = 0U; } /* The number of bytes that can be written is the minimum of the number of bytes requested and the number available. */ uxCount = FreeRTOS_min_uint32( uxSpace, uxCount ); - if( uxCount != 0u ) + if( uxCount != 0U ) { uxNextHead = pxBuffer->uxHead; - if( uxOffset != 0u ) + if( uxOffset != 0U ) { /* ( uxOffset > 0 ) means: write in front if the uxHead marker */ uxNextHead += uxOffset; @@ -86,7 +87,7 @@ size_t uxSpace, uxNextHead, uxFirst; uxFirst = FreeRTOS_min_uint32( pxBuffer->LENGTH - uxNextHead, uxCount ); /* Write as many bytes as can be written in the first write. */ - memcpy( ( void* ) ( pxBuffer->ucArray + uxNextHead ), pucData, uxFirst ); + ( void ) memcpy( &( pxBuffer->ucArray[ uxNextHead ] ), pucData, uxFirst ); /* If the number of bytes written was less than the number that could be written in the first write... */ @@ -94,11 +95,11 @@ size_t uxSpace, uxNextHead, uxFirst; { /* ...then write the remaining bytes to the start of the buffer. */ - memcpy( ( void * )pxBuffer->ucArray, pucData + uxFirst, uxCount - uxFirst ); + ( void ) memcpy( pxBuffer->ucArray, &( pucData[ uxFirst ] ), uxCount - uxFirst ); } } - if( uxOffset == 0u ) + if( uxOffset == 0U ) { /* ( uxOffset == 0 ) means: write at uxHead position */ uxNextHead += uxCount; @@ -140,17 +141,17 @@ size_t uxSize, uxCount, uxFirst, uxNextTail; } else { - uxSize = 0u; + uxSize = 0U; } /* Use the minimum of the wanted bytes and the available bytes. */ uxCount = FreeRTOS_min_uint32( uxSize, uxMaxCount ); - if( uxCount > 0u ) + if( uxCount > 0U ) { uxNextTail = pxBuffer->uxTail; - if( uxOffset != 0u ) + if( uxOffset != 0U ) { uxNextTail += uxOffset; if( uxNextTail >= pxBuffer->LENGTH ) @@ -168,14 +169,14 @@ size_t uxSize, uxCount, uxFirst, uxNextTail; /* Obtain the number of bytes it is possible to obtain in the first read. */ - memcpy( pucData, pxBuffer->ucArray + uxNextTail, uxFirst ); + ( void ) memcpy( pucData, &( pxBuffer->ucArray[ uxNextTail ] ), uxFirst ); /* If the total number of wanted bytes is greater than the number that could be read in the first read... */ if( uxCount > uxFirst ) { /*...then read the remaining bytes from the start of the buffer. */ - memcpy( pucData + uxFirst, pxBuffer->ucArray, uxCount - uxFirst ); + ( void ) memcpy( &( pucData[ uxFirst ] ), pxBuffer->ucArray, uxCount - uxFirst ); } } |