5
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief calloc() |
---|
5 | * @ingroup libcsupport |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2007. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * The license and distribution terms for this file may be |
---|
13 | * found in the file LICENSE in this distribution or at |
---|
14 | * http://www.rtems.org/license/LICENSE. |
---|
15 | */ |
---|
16 | |
---|
17 | #if HAVE_CONFIG_H |
---|
18 | #include "config.h" |
---|
19 | #endif |
---|
20 | |
---|
21 | #ifdef RTEMS_NEWLIB |
---|
22 | #include "malloc_p.h" |
---|
23 | #include <stdlib.h> |
---|
24 | |
---|
25 | void free( |
---|
26 | void *ptr |
---|
27 | ) |
---|
28 | { |
---|
29 | if ( !ptr ) |
---|
30 | return; |
---|
31 | |
---|
32 | /* |
---|
33 | * Do not attempt to free memory if in a critical section or ISR. |
---|
34 | */ |
---|
35 | if ( _Malloc_System_state() != MALLOC_SYSTEM_STATE_NORMAL ) { |
---|
36 | _Malloc_Deferred_free(ptr); |
---|
37 | return; |
---|
38 | } |
---|
39 | |
---|
40 | if ( !_Protected_heap_Free( RTEMS_Malloc_Heap, ptr ) ) { |
---|
41 | printk( "Program heap: free of bad pointer %p -- range %p - %p \n", |
---|
42 | ptr, |
---|
43 | (void*) RTEMS_Malloc_Heap->area_begin, |
---|
44 | (void*) RTEMS_Malloc_Heap->area_end |
---|
45 | ); |
---|
46 | } |
---|
47 | |
---|
48 | } |
---|
49 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.