Debian Codegraph @

vendor/unity/extras/memory/src/unity_memory.h

raw
1 /* ==========================================
2 * Unity Project - A Test Framework for C
3 * Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
4 * [Released under MIT License. Please refer to license.txt for details]
5 * ========================================== */
6
7 #ifndef UNITY_MEMORY_OVERRIDES_H_
8 #define UNITY_MEMORY_OVERRIDES_H_
9
10 #ifdef __cplusplus
11 extern "C"
12 {
13 #endif
14
15 #include <stddef.h>
16
17 #ifdef UNITY_EXCLUDE_STDLIB_MALLOC
18 /* Define this macro to remove the use of stdlib.h, malloc, and free.
19 * Many embedded systems do not have a heap or malloc/free by default.
20 * This internal unity_malloc() provides allocated memory deterministically from
21 * the end of an array only, unity_free() only releases from end-of-array,
22 * blocks are not coalesced, and memory not freed in LIFO order is stranded. */
23 #ifndef UNITY_INTERNAL_HEAP_SIZE_BYTES
24 #define UNITY_INTERNAL_HEAP_SIZE_BYTES 256
25 #endif
26 #endif
27
28 /* These functions are used by Unity to allocate and release memory
29 * on the heap and can be overridden with platform-specific implementations.
30 * For example, when using FreeRTOS UNITY_MALLOC becomes pvPortMalloc()
31 * and UNITY_FREE becomes vPortFree(). */
32 #if !defined(UNITY_MALLOC) || !defined(UNITY_FREE)
33 #include <stdlib.h>
34 #define UNITY_MALLOC(size) malloc(size)
35 #define UNITY_FREE(ptr) free(ptr)
36 #else
37 extern void* UNITY_MALLOC(size_t size);
38 extern void UNITY_FREE(void* ptr);
39 #endif
40
41 #define malloc unity_malloc
42 #define calloc unity_calloc
43 #define realloc unity_realloc
44 #define free unity_free
45
46 void* unity_malloc(size_t size);
47 void* unity_calloc(size_t num, size_t size);
48 void* unity_realloc(void * oldMem, size_t size);
49 void unity_free(void * mem);
50
51 /* You must compile with malloc replacement, as defined in unity_fixture_malloc_overrides.h */
52 void UnityMalloc_StartTest(void);
53 void UnityMalloc_EndTest(void);
54 void UnityMalloc_MakeMallocFailAfterCount(int countdown);
55
56 #ifdef __cplusplus
57 }
58 #endif
59
60 #endif