source: rtems/cpukit/posix/src/keyfreememory.c @ 64939bc

4.115
Last change on this file since 64939bc was 64939bc, checked in by Sebastian Huber <sebastian.huber@…>, on 07/12/14 at 19:22:22

rbtree: Reduce RBTree_Control size

Remove compare function and is unique indicator from the control
structure. Rename RBTree_Compare_function to RBTree_Compare. Rename
rtems_rbtree_compare_function to rtems_rbtree_compare. Provide C++
compatible initializers. Add compare function and is unique indicator
to _RBTree_Find(), _RBTree_Insert(), rtems_rbtree_find() and
rtems_rbtree_insert(). Remove _RBTree_Is_unique() and
rtems_rbtree_is_unique(). Remove compare function and is unique
indicator from _RBTree_Initialize_empty() and
rtems_rbtree_initialize_empty().

  • Property mode set to 100644
File size: 1.7 KB
Line 
1/**
2 * @file
3 *
4 * @brief POSIX Function Keys Free Memory
5 * @ingroup POSIXAPI
6 */
7
8/*
9 * Copyright (c) 2012 Zhongwei Yao.
10 * COPYRIGHT (c) 1989-2010.
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
15 * http://www.rtems.org/license/LICENSE.
16 */
17
18#if HAVE_CONFIG_H
19#include "config.h"
20#endif
21
22#include <rtems/posix/keyimpl.h>
23#include <rtems/score/chainimpl.h>
24
25void _POSIX_Keys_Free_memory(
26  POSIX_Keys_Control *the_key
27)
28{
29  POSIX_Keys_Key_value_pair search_node;
30  POSIX_Keys_Key_value_pair *p;
31  RBTree_Node *iter, *next;
32  Objects_Id key_id;
33
34  key_id = the_key->Object.id;
35  iter = _POSIX_Keys_Find( key_id, 0, &search_node );
36  if ( !iter )
37    return;
38  /**
39   * find the smallest thread_id node in the rbtree.
40   */
41  next = _RBTree_Next( iter, RBT_LEFT );
42  p = _RBTree_Container_of( next, POSIX_Keys_Key_value_pair, Key_value_lookup_node );
43  while ( next != NULL && p->key == key_id) {
44    iter = next;
45    next = _RBTree_Next( iter, RBT_LEFT );
46    p = _RBTree_Container_of( next, POSIX_Keys_Key_value_pair, Key_value_lookup_node );
47  }
48
49  /**
50   * delete all nodes belongs to the_key from the rbtree and chain.
51   */
52  p = _RBTree_Container_of( iter, POSIX_Keys_Key_value_pair, Key_value_lookup_node );
53  while ( iter != NULL && p->key == key_id ) {
54    next = _RBTree_Next( iter, RBT_RIGHT );
55    _RBTree_Extract( &_POSIX_Keys_Key_value_lookup_tree, iter );
56    _Chain_Extract_unprotected( &p->Key_values_per_thread_node );
57    _POSIX_Keys_Key_value_pair_free( p );
58
59    iter = next;
60    p = _RBTree_Container_of( iter, POSIX_Keys_Key_value_pair, Key_value_lookup_node );
61  }
62}
Note: See TracBrowser for help on using the repository browser.