summaryrefslogtreecommitdiffstats
path: root/cpukit/score/src/heapgetinfo.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-31 16:07:51 +0000
committerJoel Sherrill <joel.sherrill@OARcorp.com>2009-07-31 16:07:51 +0000
commita764317842eb8d689067bf10023b3a82a1100746 (patch)
tree2b69f4276f5d5a1a8115a7c3329be4b7193e3184 /cpukit/score/src/heapgetinfo.c
parent2009-07-30 Joel Sherrill <joel.sherrill@OARcorp.com> (diff)
downloadrtems-a764317842eb8d689067bf10023b3a82a1100746.tar.bz2
2009-07-31 Joel Sherrill <joel.sherrill@OARcorp.com>
* score/src/heapgetinfo.c: Simplify implementation.
Diffstat (limited to 'cpukit/score/src/heapgetinfo.c')
-rw-r--r--cpukit/score/src/heapgetinfo.c41
1 files changed, 19 insertions, 22 deletions
diff --git a/cpukit/score/src/heapgetinfo.c b/cpukit/score/src/heapgetinfo.c
index 525b790d07..eb06e0af69 100644
--- a/cpukit/score/src/heapgetinfo.c
+++ b/cpukit/score/src/heapgetinfo.c
@@ -1,7 +1,7 @@
/*
* Heap Handler
*
- * COPYRIGHT (c) 1989-2000.
+ * COPYRIGHT (c) 1989-2009.
* On-Line Applications Research Corporation (OAR).
*
* The license and distribution terms for this file may be
@@ -19,8 +19,7 @@
#include <rtems/score/sysstate.h>
#include <rtems/score/heap.h>
-/*PAGE
- *
+/*
* _Heap_Get_information
*
* This kernel routine walks the heap and tots up the free and allocated
@@ -34,7 +33,6 @@
* *the_info - contains information about heap
* return 0=success, otherwise heap is corrupt.
*/
-
Heap_Get_information_status _Heap_Get_information(
Heap_Control *the_heap,
Heap_Information_block *the_info
@@ -54,29 +52,28 @@ Heap_Get_information_status _Heap_Get_information(
the_info->Used.largest = 0;
while ( the_block != end ) {
- uint32_t const the_size = _Heap_Block_size(the_block);
- Heap_Block *const next_block = _Heap_Block_at(the_block, the_size);
+ uint32_t const the_size = _Heap_Block_size(the_block);
+ Heap_Block *const next_block = _Heap_Block_at(the_block, the_size);
+ Heap_Information *info;
+
+ if ( _Heap_Is_prev_used(next_block) )
+ info = &the_info->Used;
+ else
+ info = &the_info->Free;
- if ( _Heap_Is_prev_used(next_block) ) {
- the_info->Used.number++;
- the_info->Used.total += the_size;
- if ( the_info->Used.largest < the_size )
- the_info->Used.largest = the_size;
- } else {
- the_info->Free.number++;
- the_info->Free.total += the_size;
- if ( the_info->Free.largest < the_size )
- the_info->Free.largest = the_size;
- if ( the_size != next_block->prev_size )
- return HEAP_GET_INFORMATION_BLOCK_ERROR;
- }
+ info->number++;
+ info->total += the_size;
+ if ( info->largest < the_size )
+ info->largest = the_size;
the_block = next_block;
}
- /* Handle the last dummy block. Don't consider this block to be
- "used" as client never allocated it. Make 'Used.total' contain this
- blocks' overhead though. */
+ /*
+ * Handle the last dummy block. Don't consider this block to be
+ * "used" as client never allocated it. Make 'Used.total' contain this
+ * blocks' overhead though.
+ */
the_info->Used.total += HEAP_OVERHEAD;
return HEAP_GET_INFORMATION_SUCCESSFUL;