diff --git a/src/unity.c b/src/unity.c index 380fc91..9e42f75 100644 --- a/src/unity.c +++ b/src/unity.c @@ -539,6 +539,8 @@ void UnityAssertEqualMemoryArray(const void* expected, const char* msg, const unsigned short lineNumber) { + unsigned char* expected_ptr = (unsigned char*)expected; + unsigned char* actual_ptr = (unsigned char*)actual; unsigned long elements = num_elements; if ((elements == 0) || (length == 0)) { @@ -556,22 +558,22 @@ void UnityAssertEqualMemoryArray(const void* expected, } // if both pointers not null compare the memory - if (expected && actual) + if (expected_ptr && actual_ptr) { while (elements--) { - if (memcmp(expected, actual, length) != 0) + if (memcmp((const void*)expected_ptr, (const void*)actual_ptr, length) != 0) { Unity.CurrentTestFailed = 1; break; } - expected += length; - actual += length; + expected_ptr += length; + actual_ptr += length; } } else { // handle case of one pointers being null (if both null, test should pass) - if (expected != actual) + if (expected_ptr != actual_ptr) { Unity.CurrentTestFailed = 1; } diff --git a/src/unity.h b/src/unity.h index f8c69fe..1b52da5 100644 --- a/src/unity.h +++ b/src/unity.h @@ -141,11 +141,11 @@ void UnityAssertEqualMemory(const void* expected, const unsigned short lineNumber ); void UnityAssertEqualMemoryArray(const void* expected, - const void* actual, - unsigned long length, - unsigned long num_elements, - const char* msg, - const unsigned short lineNumber ); + const void* actual, + unsigned long length, + unsigned long num_elements, + const char* msg, + const unsigned short lineNumber ); void UnityAssertFloatsWithin(const float delta, const float expected,