提交 254ba805 编写于 作者: M Mark VanderVoord

Merge pull request #117 from aburks/master

Fixes issues #3 and #116 (Thanks!)
......@@ -196,7 +196,7 @@ void * unity_malloc(size_t size)
malloc_count++;
guard = (Guard*)malloc(size + sizeof(Guard) + 4);
guard = (Guard*)UNITY_FIXTURE_MALLOC(size + sizeof(Guard) + 4);
guard->size = size;
mem = (char*)&(guard[1]);
memcpy(&mem[size], end, strlen(end) + 1);
......@@ -219,7 +219,7 @@ static void release_memory(void * mem)
guard--;
malloc_count--;
free(guard);
UNITY_FIXTURE_FREE(guard);
}
void unity_free(void * mem)
......
......@@ -8,6 +8,30 @@
#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_
#define UNITY_FIXTURE_MALLOC_OVERRIDES_H_
#include <stddef.h>
// 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 ) )
#else
extern void UNITY_FIXTURE_FREE(void *ptr);
#endif
#define malloc unity_malloc
#define calloc unity_calloc
#define realloc unity_realloc
......
......@@ -5,6 +5,7 @@
============================================================================ */
#include "unity.h"
#include <stddef.h>
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册