4.104.114.95
Line | |
---|
1 | /* |
---|
2 | * calloc() |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2007. |
---|
5 | * On-Line Applications Research Corporation (OAR). |
---|
6 | * |
---|
7 | * The license and distribution terms for this file may be |
---|
8 | * found in the file LICENSE in this distribution or at |
---|
9 | * http://www.rtems.com/license/LICENSE. |
---|
10 | * |
---|
11 | * $Id$ |
---|
12 | */ |
---|
13 | |
---|
14 | #if HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #ifdef RTEMS_NEWLIB |
---|
19 | #include "malloc_p.h" |
---|
20 | #include <stdlib.h> |
---|
21 | |
---|
22 | void free( |
---|
23 | void *ptr |
---|
24 | ) |
---|
25 | { |
---|
26 | MSBUMP(free_calls, 1); |
---|
27 | |
---|
28 | if ( !ptr ) |
---|
29 | return; |
---|
30 | |
---|
31 | #if defined(RTEMS_HEAP_DEBUG) |
---|
32 | _Protected_heap_Walk( &RTEMS_Malloc_Heap, 0, false ); |
---|
33 | #endif |
---|
34 | |
---|
35 | /* |
---|
36 | * Do not attempt to free memory if in a critical section or ISR. |
---|
37 | */ |
---|
38 | |
---|
39 | if ( _System_state_Is_up(_System_state_Get()) && |
---|
40 | !malloc_is_system_state_OK() ) { |
---|
41 | malloc_deferred_free(ptr); |
---|
42 | return; |
---|
43 | } |
---|
44 | |
---|
45 | #if defined(RTEMS_MALLOC_BOUNDARY_HELPERS) |
---|
46 | /* |
---|
47 | * If configured, check the boundary area |
---|
48 | */ |
---|
49 | if ( rtems_malloc_boundary_helpers ) |
---|
50 | (*rtems_malloc_boundary_helpers->at_free)(ptr); |
---|
51 | #endif |
---|
52 | |
---|
53 | /* |
---|
54 | * If configured, update the statistics |
---|
55 | */ |
---|
56 | if ( rtems_malloc_statistics_helpers ) |
---|
57 | (*rtems_malloc_statistics_helpers->at_free)(ptr); |
---|
58 | |
---|
59 | if ( !_Protected_heap_Free( &RTEMS_Malloc_Heap, ptr ) ) { |
---|
60 | printk( "Program heap: free of bad pointer %p -- range %p - %p \n", |
---|
61 | ptr, |
---|
62 | RTEMS_Malloc_Heap.start, |
---|
63 | RTEMS_Malloc_Heap.end |
---|
64 | ); |
---|
65 | } |
---|
66 | |
---|
67 | } |
---|
68 | #endif |
---|
Note: See
TracBrowser
for help on using the repository browser.