diff --git a/extras/fixture/src/unity_fixture.c b/extras/fixture/src/unity_fixture.c index c4d0af25f524ac7e6ac7dfe41dcbc384d6f892ae..b28e30fb54f35e1031a4fe97c26115d5c0ece753 100644 --- a/extras/fixture/src/unity_fixture.c +++ b/extras/fixture/src/unity_fixture.c @@ -149,21 +149,12 @@ void UnityMalloc_MakeMallocFailAfterCount(int countdown) malloc_fail_countdown = countdown; } -#ifdef malloc +// These definitions are always included from unity_fixture_malloc_overrides.h +// We undef to use them or avoid conflict with per the C standard #undef malloc -#endif - -#ifdef free #undef free -#endif - -#ifdef calloc #undef calloc -#endif - -#ifdef realloc #undef realloc -#endif #include @@ -290,7 +281,7 @@ void UnityPointer_Init(void) pointer_index = 0; } -void UnityPointer_Set(void ** pointer, void * newValue) +void UnityPointer_Set(void** pointer, void* newValue) { if (pointer_index >= MAX_POINTERS) { @@ -311,8 +302,7 @@ void UnityPointer_UndoAllSets(void) { pointer_index--; *(pointer_store[pointer_index].pointer) = - pointer_store[pointer_index].old_value; - + pointer_store[pointer_index].old_value; } } @@ -373,7 +363,13 @@ int UnityGetCommandLineOptions(int argc, const char* argv[]) { if (*(argv[i]) >= '0' && *(argv[i]) <= '9') { - UnityFixture.RepeatCount = atoi(argv[i]); + unsigned int digit = 0; + UnityFixture.RepeatCount = 0; + while (argv[i][digit] >= '0' && argv[i][digit] <= '9') + { + UnityFixture.RepeatCount *= 10; + UnityFixture.RepeatCount += (unsigned int)argv[i][digit++] - '0'; + } i++; } } diff --git a/extras/fixture/src/unity_fixture_malloc_overrides.h b/extras/fixture/src/unity_fixture_malloc_overrides.h index 27b9884f051de05388a94e6f6c09e63d6c12f960..cc9c42b39005101eafec24399813bd8e7474ed74 100644 --- a/extras/fixture/src/unity_fixture_malloc_overrides.h +++ b/extras/fixture/src/unity_fixture_malloc_overrides.h @@ -10,26 +10,17 @@ #include -// This function is used by the Unity Fixture to allocate memory on -// the heap and can be overridden with platform-specific heap -// implementations. For example, when using FreeRTOS -// UNITY_FIXTURE_MALLOC becomes pvPortMalloc(). - -#ifndef UNITY_FIXTURE_MALLOC - #define UNITY_FIXTURE_MALLOC( SIZE ) malloc( ( SIZE ) ) -#else - extern void * UNITY_FIXTURE_MALLOC(size_t size); -#endif - -// This function is used by the Unity Fixture to release memory in the -// heap and can be overridden with platform-specific heap -// implementations. For example, when using FreeRTOS -// UNITY_FIXTURE_FREE becomes vPortFree(). - -#ifndef UNITY_FIXTURE_FREE - #define UNITY_FIXTURE_FREE( PTR ) free( ( PTR ) ) +// These functions are used by the Unity Fixture to allocate and release memory +// on the heap and can be overridden with platform-specific implementations. +// For example, when using FreeRTOS UNITY_FIXTURE_MALLOC becomes pvPortMalloc() +// and UNITY_FIXTURE_FREE becomes vPortFree(). + +#if !defined(UNITY_FIXTURE_MALLOC) || !defined(UNITY_FIXTURE_FREE) + #define UNITY_FIXTURE_MALLOC(size) malloc(size) + #define UNITY_FIXTURE_FREE(ptr) free(ptr) #else - extern void UNITY_FIXTURE_FREE(void *ptr); + extern void* UNITY_FIXTURE_MALLOC(size_t size); + extern void UNITY_FIXTURE_FREE(void* ptr); #endif #define malloc unity_malloc