4.104.114.84.95
Line | |
---|
1 | /* |
---|
2 | * Heap Handler |
---|
3 | * |
---|
4 | * COPYRIGHT (c) 1989-2004. |
---|
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 | #include <rtems/system.h> |
---|
19 | #include <rtems/score/sysstate.h> |
---|
20 | #include <rtems/score/heap.h> |
---|
21 | |
---|
22 | /*PAGE |
---|
23 | * |
---|
24 | * _Heap_Get_free_information |
---|
25 | * |
---|
26 | * This heap routine returns information about the free blocks |
---|
27 | * in the specified heap. |
---|
28 | * |
---|
29 | * Input parameters: |
---|
30 | * the_heap - pointer to heap header. |
---|
31 | * info - pointer to the free block information. |
---|
32 | * |
---|
33 | * Output parameters: |
---|
34 | * returns - free block information filled in. |
---|
35 | */ |
---|
36 | |
---|
37 | void _Heap_Get_free_information( |
---|
38 | Heap_Control *the_heap, |
---|
39 | Heap_Information *info |
---|
40 | ) |
---|
41 | { |
---|
42 | Heap_Block *the_block; |
---|
43 | Heap_Block *const tail = _Heap_Tail(the_heap); |
---|
44 | |
---|
45 | info->number = 0; |
---|
46 | info->largest = 0; |
---|
47 | info->total = 0; |
---|
48 | |
---|
49 | for(the_block = _Heap_First(the_heap); |
---|
50 | the_block != tail; |
---|
51 | the_block = the_block->next) |
---|
52 | { |
---|
53 | uint32_t const the_size = _Heap_Block_size(the_block); |
---|
54 | |
---|
55 | /* As we always coalesce free blocks, prev block must have been used. */ |
---|
56 | _HAssert(_Heap_Is_prev_used(the_block)); |
---|
57 | |
---|
58 | info->number++; |
---|
59 | info->total += the_size; |
---|
60 | if ( info->largest < the_size ) |
---|
61 | info->largest = the_size; |
---|
62 | } |
---|
63 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.