mirror of
https://github.com/ThrowTheSwitch/Unity.git
synced 2025-06-27 04:52:37 +08:00
Merge pull request #117 from aburks/master
Fixes issues #3 and #116 (Thanks!)
This commit is contained in:
@ -196,7 +196,7 @@ void * unity_malloc(size_t size)
|
|||||||
|
|
||||||
malloc_count++;
|
malloc_count++;
|
||||||
|
|
||||||
guard = (Guard*)malloc(size + sizeof(Guard) + 4);
|
guard = (Guard*)UNITY_FIXTURE_MALLOC(size + sizeof(Guard) + 4);
|
||||||
guard->size = size;
|
guard->size = size;
|
||||||
mem = (char*)&(guard[1]);
|
mem = (char*)&(guard[1]);
|
||||||
memcpy(&mem[size], end, strlen(end) + 1);
|
memcpy(&mem[size], end, strlen(end) + 1);
|
||||||
@ -219,7 +219,7 @@ static void release_memory(void * mem)
|
|||||||
guard--;
|
guard--;
|
||||||
|
|
||||||
malloc_count--;
|
malloc_count--;
|
||||||
free(guard);
|
UNITY_FIXTURE_FREE(guard);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unity_free(void * mem)
|
void unity_free(void * mem)
|
||||||
|
@ -8,6 +8,30 @@
|
|||||||
#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_
|
#ifndef UNITY_FIXTURE_MALLOC_OVERRIDES_H_
|
||||||
#define 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 malloc unity_malloc
|
||||||
#define calloc unity_calloc
|
#define calloc unity_calloc
|
||||||
#define realloc unity_realloc
|
#define realloc unity_realloc
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
============================================================================ */
|
============================================================================ */
|
||||||
|
|
||||||
#include "unity.h"
|
#include "unity.h"
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
|
#define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; longjmp(Unity.AbortFrame, 1); }
|
||||||
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
|
#define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; longjmp(Unity.AbortFrame, 1); }
|
||||||
|
Reference in New Issue
Block a user