| 318 | #if ( configSUPPORT_STATIC_ALLOCATION == 1 ) |
| 319 | |
| 320 | QueueHandle_t xQueueGenericCreateStatic( const UBaseType_t uxQueueLength, |
| 321 | const UBaseType_t uxItemSize, |
| 322 | uint8_t * pucQueueStorage, |
| 323 | StaticQueue_t * pxStaticQueue, |
| 324 | const uint8_t ucQueueType ) |
| 325 | { |
| 326 | Queue_t * pxNewQueue; |
| 327 | |
| 328 | configASSERT( uxQueueLength > ( UBaseType_t ) 0 ); |
| 329 | |
| 330 | /* The StaticQueue_t structure and the queue storage area must be |
| 331 | * supplied. */ |
| 332 | configASSERT( pxStaticQueue != NULL ); |
| 333 | |
| 334 | /* A queue storage area should be provided if the item size is not 0, and |
| 335 | * should not be provided if the item size is 0. */ |
| 336 | configASSERT( !( ( pucQueueStorage != NULL ) && ( uxItemSize == 0 ) ) ); |
| 337 | configASSERT( !( ( pucQueueStorage == NULL ) && ( uxItemSize != 0 ) ) ); |
| 338 | |
| 339 | #if ( configASSERT_DEFINED == 1 ) |
| 340 | { |
| 341 | /* Sanity check that the size of the structure used to declare a |
| 342 | * variable of type StaticQueue_t or StaticSemaphore_t equals the size of |
| 343 | * the real queue and semaphore structures. */ |
| 344 | volatile size_t xSize = sizeof( StaticQueue_t ); |
| 345 | |
| 346 | /* This assertion cannot be branch covered in unit tests */ |
| 347 | configASSERT( xSize == sizeof( Queue_t ) ); /* LCOV_EXCL_BR_LINE */ |
| 348 | ( void ) xSize; /* Keeps lint quiet when configASSERT() is not defined. */ |
| 349 | } |
| 350 | #endif /* configASSERT_DEFINED */ |
| 351 | |
| 352 | /* The address of a statically allocated queue was passed in, use it. |
| 353 | * The address of a statically allocated storage area was also passed in |
| 354 | * but is already set. */ |
| 355 | pxNewQueue = ( Queue_t * ) pxStaticQueue; /*lint !e740 !e9087 Unusual cast is ok as the structures are designed to have the same alignment, and the size is checked by an assert. */ |
| 356 | |
| 357 | if( pxNewQueue != NULL ) |
| 358 | { |
| 359 | #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 ) |
| 360 | { |
| 361 | /* Queues can be allocated wither statically or dynamically, so |
| 362 | * note this queue was allocated statically in case the queue is |
| 363 | * later deleted. */ |
| 364 | pxNewQueue->ucStaticallyAllocated = pdTRUE; |
| 365 | } |
| 366 | #endif /* configSUPPORT_DYNAMIC_ALLOCATION */ |
| 367 | |
| 368 | prvInitialiseNewQueue( uxQueueLength, uxItemSize, pucQueueStorage, ucQueueType, pxNewQueue ); |
| 369 | } |
| 370 | else |
| 371 | { |
| 372 | traceQUEUE_CREATE_FAILED( ucQueueType ); |
| 373 | mtCOVERAGE_TEST_MARKER(); |
| 374 | } |
| 375 | |
| 376 | return pxNewQueue; |
| 377 | } |
no test coverage detected