From a89ae540c1d287d275943fd06692a44e9dbc8331 Mon Sep 17 00:00:00 2001 From: Sebastian Huber Date: Tue, 6 Dec 2011 14:23:26 +0000 Subject: 2011-12-06 Sebastian Huber * score/src/heapiterate.c, score/src/pheapiterate.c: New files. * score/Makefile.am: Reflect changes above. * score/include/rtems/score/heap.h: Declare _Heap_Iterate() and define Heap_Block_visitor. * score/include/rtems/score/protectedheap.h: Declare _Protected_heap_Iterate(). * score/src/heapgetinfo.c: Use _Heap_Iterate(). --- cpukit/score/src/heapiterate.c | 50 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 cpukit/score/src/heapiterate.c (limited to 'cpukit/score/src/heapiterate.c') diff --git a/cpukit/score/src/heapiterate.c b/cpukit/score/src/heapiterate.c new file mode 100644 index 0000000000..b9100b9149 --- /dev/null +++ b/cpukit/score/src/heapiterate.c @@ -0,0 +1,50 @@ +/** + * @file + * + * @ingroup ScoreHeap + * + * @brief _Heap_Iterate() implementation. + */ + +/* + * Copyright (c) 2011 embedded brains GmbH. All rights reserved. + * + * embedded brains GmbH + * Obere Lagerstr. 30 + * 82178 Puchheim + * Germany + * + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.rtems.com/license/LICENSE. + * + * $Id$ + */ + +#if HAVE_CONFIG_H + #include "config.h" +#endif + +#include + +void _Heap_Iterate( + Heap_Control *heap, + Heap_Block_visitor visitor, + void *visitor_arg +) +{ + Heap_Block *current = heap->first_block; + Heap_Block *end = heap->last_block; + bool stop = false; + + while ( !stop && current != end ) { + uintptr_t size = _Heap_Block_size( current ); + Heap_Block *next = _Heap_Block_at( current, size ); + bool used = _Heap_Is_prev_used( next ); + + stop = (*visitor)( current, size, used, visitor_arg ); + + current = next; + } +} -- cgit v1.2.3