4.115
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.com/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 | MSBUMP(free_calls, 1); |
---|
30 | |
---|
31 | if ( !ptr ) |
---|
32 | return; |
---|
33 | |
---|
34 | /* |
---|
35 | * Do not attempt to free memory if in a critical section or ISR. |
---|
36 | */ |
---|
37 | if ( _System_state_Is_up(_System_state_Get()) && |
---|
38 | !malloc_is_system_state_OK() ) { |
---|
39 | malloc_deferred_free(ptr); |
---|
40 | return; |
---|
41 | } |
---|
42 | |
---|
43 | /* |
---|
44 | * If configured, update the statistics |
---|
45 | */ |
---|
46 | if ( rtems_malloc_statistics_helpers ) |
---|
47 | (*rtems_malloc_statistics_helpers->at_free)(ptr); |
---|
48 | |
---|
49 | if ( !_Protected_heap_Free( RTEMS_Malloc_Heap, ptr ) ) { |
---|
50 | printk( "Program heap: free of bad pointer %p -- range %p - %p \n", |
---|
51 | ptr, |
---|
52 | RTEMS_Malloc_Heap->area_begin, |
---|
53 | RTEMS_Malloc_Heap->area_end |
---|
54 | ); |
---|
55 | } |
---|
56 | |
---|
57 | } |
---|
58 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.