source: rtems/cpukit/libdl/rtl-chain-iterator.c @ 4408603

Last change on this file since 4408603 was d4edbdbc, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 20, 2015 at 1:09:26 PM

Replace www.rtems.com with www.rtems.org

  • Property mode set to 100644
File size: 1.2 KB
Line 
1/*
2 *  COPYRIGHT (c) 2012 Chris Johns <chrisj@rtems.org>
3 *
4 *  The license and distribution terms for this file may be
5 *  found in the file LICENSE in this distribution or at
6 *  http://www.rtems.org/license/LICENSE.
7 */
8/**
9 * @file
10 *
11 * @ingroup rtems_rtld
12 *
13 * @brief RTEMS Run-Time Link Editor Chain Iterator
14 *
15 * A means of executing an iterator on a chain.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include "rtl-chain-iterator.h"
23
24bool
25rtems_rtl_chain_iterate (rtems_chain_control* chain,
26                         rtems_chain_iterator iterator,
27                         void*                data)
28{
29  rtems_chain_node* node = rtems_chain_first (chain);
30  while (!rtems_chain_is_tail (chain, node))
31  {
32    rtems_chain_node* next_node = rtems_chain_next (node);
33    if (!iterator (node, data))
34      return false;
35    node = next_node;
36  }
37  return true;
38}
39
40/**
41 * Count iterator.
42 */
43static bool
44rtems_rtl_count_iterator (rtems_chain_node* node, void* data)
45{
46  int* count = data;
47  ++(*count);
48  return true;
49}
50
51int
52rtems_rtl_chain_count (rtems_chain_control* chain)
53{
54  int count = 0;
55  rtems_rtl_chain_iterate (chain, rtems_rtl_count_iterator, &count);
56  return count;
57}
Note: See TracBrowser for help on using the repository browser.