]> git.sur5r.net Git - freertos/commitdiff
Fix build failure when dynamic allocation is not enabled.
authorgaurav-aws <gaurav-aws@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sat, 16 Feb 2019 20:21:47 +0000 (20:21 +0000)
committergaurav-aws <gaurav-aws@1d2547de-c912-0410-9cb9-b8ca96c0e9e2>
Sat, 16 Feb 2019 20:21:47 +0000 (20:21 +0000)
When dynamic allocation is not enabled, vPortFree is not available. The current code used
vPortFree and this resulted in linker error. This commit removes the use of vPortFree when
dynamic allocation is not enabled.

git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2631 1d2547de-c912-0410-9cb9-b8ca96c0e9e2

FreeRTOS/Source/timers.c

index 3c0b4626727571f288d946a2ac07f1301f2ac156..51dfa0ce61ec99825a013ee13deae663f4ee103f 100644 (file)
@@ -301,7 +301,7 @@ BaseType_t xReturn = pdFAIL;
                return pxNewTimer;\r
        }\r
 \r
-#endif /* configSUPPORT_STATIC_ALLOCATION */\r
+#endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
 /*-----------------------------------------------------------*/\r
 \r
 #if( configSUPPORT_STATIC_ALLOCATION == 1 )\r
@@ -820,17 +820,29 @@ TickType_t xTimeNow;
                                        break;\r
 \r
                                case tmrCOMMAND_DELETE :\r
-                                       /* 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->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 )\r
+                                       #if ( configSUPPORT_DYNAMIC_ALLOCATION == 1 )\r
                                        {\r
-                                               vPortFree( pxTimer );\r
+                                               /* 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->ucStatus & tmrSTATUS_IS_STATICALLY_ALLOCATED ) == ( uint8_t ) 0 )\r
+                                               {\r
+                                                       vPortFree( pxTimer );\r
+                                               }\r
+                                               else\r
+                                               {\r
+                                                       pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;\r
+                                               }\r
                                        }\r
-                                       else\r
+                                       #else\r
                                        {\r
+                                               /* If dynamic allocation is not enabled, the memory\r
+                                               could not have been dynamically allocated. So there is\r
+                                               no need to free the memory - just mark the timer as\r
+                                               "not active". */\r
                                                pxTimer->ucStatus &= ~tmrSTATUS_IS_ACTIVE;\r
                                        }\r
+                                       #endif /* configSUPPORT_DYNAMIC_ALLOCATION */\r
                                        break;\r
 \r
                                default :\r