]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Source/timers.c
Ensure the code builds when configSUPPORT_STATIC_ALLOCATION is 0.
[freertos] / FreeRTOS / Source / timers.c
index 904189dc2316934cf8b1501800538fbf73c407c2..1dd62ef589f08b68f7f81716f41fbd8669973477 100644 (file)
@@ -298,7 +298,7 @@ uint16_t usTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-TimerHandle_t xTimerGenericCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxStaticTimer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
+TimerHandle_t xTimerGenericCreate( const char * const pcTimerName, const TickType_t xTimerPeriodInTicks, const UBaseType_t uxAutoReload, void * const pvTimerID, TimerCallbackFunction_t pxCallbackFunction, StaticTimer_t *pxTimerBuffer ) /*lint !e971 Unqualified char types are allowed for strings and single characters only. */\r
 {\r
 Timer_t *pxNewTimer;\r
 \r
@@ -321,13 +321,13 @@ Timer_t *pxNewTimer;
        {\r
                /* If the user passed in a statically allocated timer structure then use\r
                it, otherwise allocate the structure dynamically. */\r
-               if( pxStaticTimer == NULL )\r
+               if( pxTimerBuffer == NULL )\r
                {\r
                        pxNewTimer = ( Timer_t * ) pvPortMalloc( sizeof( Timer_t ) );\r
                }\r
                else\r
                {\r
-                       pxNewTimer = ( Timer_t * ) pxStaticTimer;\r
+                       pxNewTimer = ( Timer_t * ) pxTimerBuffer;\r
                }\r
 \r
                if( pxNewTimer != NULL )\r
@@ -345,14 +345,18 @@ Timer_t *pxNewTimer;
                        pxNewTimer->pxCallbackFunction = pxCallbackFunction;\r
                        vListInitialiseItem( &( pxNewTimer->xTimerListItem ) );\r
 \r
-                       if( pxStaticTimer == NULL )\r
+                       #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
                        {\r
-                               pxNewTimer->ucStaticallyAllocated = pdFALSE;\r
-                       }\r
-                       else\r
-                       {\r
-                               pxNewTimer->ucStaticallyAllocated = pdTRUE;\r
+                               if( pxTimerBuffer == NULL )\r
+                               {\r
+                                       pxNewTimer->ucStaticallyAllocated = pdFALSE;\r
+                               }\r
+                               else\r
+                               {\r
+                                       pxNewTimer->ucStaticallyAllocated = pdTRUE;\r
+                               }\r
                        }\r
+                       #endif /* configSUPPORT_STATIC_ALLOCATION */\r
 \r
                        traceTIMER_CREATE( pxNewTimer );\r
                }\r
@@ -763,14 +767,22 @@ TickType_t xTimeNow;
                                        /* The timer has already been removed from the active list,\r
                                        just free up the memory if the memory was dynamically\r
                                        allocated. */\r
-                                       if( pxTimer->ucStaticallyAllocated == pdFALSE )\r
+                                       #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
                                        {\r
-                                               vPortFree( pxTimer );\r
+                                               if( pxTimer->ucStaticallyAllocated == pdFALSE )\r
+                                               {\r
+                                                       vPortFree( pxTimer );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       mtCOVERAGE_TEST_MARKER();\r
+                                               }\r
                                        }\r
-                                       else\r
+                                       #else\r
                                        {\r
-                                               mtCOVERAGE_TEST_MARKER();\r
+                                               vPortFree( pxTimer );\r
                                        }\r
+                                       #endif /* configSUPPORT_STATIC_ALLOCATION */\r
                                        break;\r
 \r
                                default :\r