source:
rtems/cpukit/score/src/heapgetinfo.c
@
7121a9fa
Last change on this file since 7121a9fa was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24 | |
---|---|
|
|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[dea3eccb] | 1 | /** |
2 | * @file | |
3 | * | |
4 | * @ingroup ScoreHeap | |
[252565f] | 5 | * |
[dea3eccb] | 6 | * @brief Heap Handler implementation. |
7 | */ | |
8 | ||
9 | /* | |
[a7643178] | 10 | * COPYRIGHT (c) 1989-2009. |
[252565f] | 11 | * On-Line Applications Research Corporation (OAR). |
12 | * | |
13 | * The license and distribution terms for this file may be | |
14 | * found in the file LICENSE in this distribution or at | |
[dd687d97] | 15 | * http://www.rtems.com/license/LICENSE. |
[252565f] | 16 | */ |
17 | ||
[a8eed23] | 18 | #if HAVE_CONFIG_H |
19 | #include "config.h" | |
20 | #endif | |
[252565f] | 21 | |
[b2a0214] | 22 | #include <string.h> |
23 | ||
[252565f] | 24 | #include <rtems/score/heap.h> |
25 | ||
[a89ae540] | 26 | static bool _Heap_Get_information_visitor( |
27 | const Heap_Block *block __attribute__((unused)), | |
28 | uintptr_t block_size, | |
29 | bool block_is_used, | |
30 | void *visitor_arg | |
[252565f] | 31 | ) |
32 | { | |
[a89ae540] | 33 | Heap_Information_block *info_block = visitor_arg; |
34 | Heap_Information *info = block_is_used ? | |
35 | &info_block->Used : &info_block->Free; | |
[252565f] | 36 | |
[a89ae540] | 37 | ++info->number; |
38 | info->total += block_size; | |
39 | if ( info->largest < block_size ) | |
40 | info->largest = block_size; | |
[252565f] | 41 | |
[a89ae540] | 42 | return false; |
43 | } | |
[962e894f] | 44 | |
[a89ae540] | 45 | void _Heap_Get_information( |
46 | Heap_Control *the_heap, | |
47 | Heap_Information_block *the_info | |
48 | ) | |
49 | { | |
50 | memset( the_info, 0, sizeof(*the_info) ); | |
51 | _Heap_Iterate( the_heap, _Heap_Get_information_visitor, the_info ); | |
[252565f] | 52 | } |
Note: See TracBrowser
for help on using the repository browser.