1 |
/* |
---|
2 |
FreeRTOS V5.4.1 - Copyright (C) 2009 Real Time Engineers Ltd. |
---|
3 |
|
---|
4 |
This file is part of the FreeRTOS distribution. |
---|
5 |
|
---|
6 |
FreeRTOS is free software; you can redistribute it and/or modify it under |
---|
7 |
the terms of the GNU General Public License (version 2) as published by the |
---|
8 |
Free Software Foundation and modified by the FreeRTOS exception. |
---|
9 |
**NOTE** The exception to the GPL is included to allow you to distribute a |
---|
10 |
combined work that includes FreeRTOS without being obliged to provide the |
---|
11 |
source code for proprietary components outside of the FreeRTOS kernel. |
---|
12 |
Alternative commercial license and support terms are also available upon |
---|
13 |
request. See the licensing section of http://www.FreeRTOS.org for full |
---|
14 |
license details. |
---|
15 |
|
---|
16 |
FreeRTOS is distributed in the hope that it will be useful, but WITHOUT |
---|
17 |
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
18 |
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
---|
19 |
more details. |
---|
20 |
|
---|
21 |
You should have received a copy of the GNU General Public License along |
---|
22 |
with FreeRTOS; if not, write to the Free Software Foundation, Inc., 59 |
---|
23 |
Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
---|
24 |
|
---|
25 |
|
---|
26 |
*************************************************************************** |
---|
27 |
* * |
---|
28 |
* Looking for a quick start? Then check out the FreeRTOS eBook! * |
---|
29 |
* See http://www.FreeRTOS.org/Documentation for details * |
---|
30 |
* * |
---|
31 |
*************************************************************************** |
---|
32 |
|
---|
33 |
1 tab == 4 spaces! |
---|
34 |
|
---|
35 |
Please ensure to read the configuration and relevant port sections of the |
---|
36 |
online documentation. |
---|
37 |
|
---|
38 |
http://www.FreeRTOS.org - Documentation, latest information, license and |
---|
39 |
contact details. |
---|
40 |
|
---|
41 |
http://www.SafeRTOS.com - A version that is certified for use in safety |
---|
42 |
critical systems. |
---|
43 |
|
---|
44 |
http://www.OpenRTOS.com - Commercial support, development, porting, |
---|
45 |
licensing and training services. |
---|
46 |
*/ |
---|
47 |
|
---|
48 |
|
---|
49 |
/* |
---|
50 |
* Implementation of pvPortMalloc() and vPortFree() that relies on the |
---|
51 |
* compilers own malloc() and free() implementations. |
---|
52 |
* |
---|
53 |
* This file can only be used if the linker is configured to to generate |
---|
54 |
* a heap memory area. |
---|
55 |
* |
---|
56 |
* See heap_2.c and heap_1.c for alternative implementations, and the memory |
---|
57 |
* management pages of http://www.FreeRTOS.org for more information. |
---|
58 |
*/ |
---|
59 |
|
---|
60 |
#include <stdlib.h> |
---|
61 |
|
---|
62 |
#include "FreeRTOS.h" |
---|
63 |
#include "task.h" |
---|
64 |
|
---|
65 |
/*-----------------------------------------------------------*/ |
---|
66 |
|
---|
67 |
void *pvPortMalloc( size_t xWantedSize ) |
---|
68 |
{ |
---|
69 |
void *pvReturn; |
---|
70 |
|
---|
71 |
vTaskSuspendAll(); |
---|
72 |
{ |
---|
73 |
pvReturn = malloc( xWantedSize ); |
---|
74 |
} |
---|
75 |
xTaskResumeAll(); |
---|
76 |
|
---|
77 |
#if( configUSE_MALLOC_FAILED_HOOK == 1 ) |
---|
78 |
{ |
---|
79 |
if( pvReturn == NULL ) |
---|
80 |
{ |
---|
81 |
extern void vApplicationMallocFailedHook( void ); |
---|
82 |
vApplicationMallocFailedHook(); |
---|
83 |
} |
---|
84 |
} |
---|
85 |
#endif |
---|
86 |
|
---|
87 |
return pvReturn; |
---|
88 |
} |
---|
89 |
/*-----------------------------------------------------------*/ |
---|
90 |
|
---|
91 |
void vPortFree( void *pv ) |
---|
92 |
{ |
---|
93 |
if( pv ) |
---|
94 |
{ |
---|
95 |
vTaskSuspendAll(); |
---|
96 |
{ |
---|
97 |
free( pv ); |
---|
98 |
} |
---|
99 |
xTaskResumeAll(); |
---|
100 |
} |
---|
101 |
} |
---|
102 |
|
---|
103 |
|
---|
104 |
|
---|