]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.0.0/liblfds700/src/lfds700_hash_addonly/lfds700_hash_addonly_cleanup.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.0.0 / liblfds700 / src / lfds700_hash_addonly / lfds700_hash_addonly_cleanup.c
1 /***** includes *****/
2 #include "lfds700_hash_addonly_internal.h"
3
4 /***** private prototypes*****/
5 static void btree_au_element_cleanup_function( struct lfds700_btree_au_state *baus, struct lfds700_btree_au_element *baue );
6
7
8
9
10
11 /****************************************************************************/
12 void lfds700_hash_a_cleanup( struct lfds700_hash_a_state *has,
13                              void (*element_cleanup_callback)(struct lfds700_hash_a_state *has, struct lfds700_hash_a_element *hae) )
14 {
15   lfds700_pal_uint_t
16     loop;
17
18   LFDS700_PAL_ASSERT( has != NULL );
19   // TRD : element_cleanup_callback can be NULL
20
21   if( element_cleanup_callback == NULL )
22     return;
23
24   LFDS700_MISC_BARRIER_LOAD;
25
26   has->element_cleanup_callback = element_cleanup_callback;
27
28   for( loop = 0 ; loop < has->array_size ; loop++ )
29     lfds700_btree_au_cleanup( has->baus_array+loop, btree_au_element_cleanup_function );
30
31   return;
32 }
33
34
35
36
37
38 /****************************************************************************/
39 #pragma warning( disable : 4100 )
40
41 static void btree_au_element_cleanup_function( struct lfds700_btree_au_state *baus, struct lfds700_btree_au_element *baue )
42 {
43   struct lfds700_hash_a_state
44     *has;
45
46   struct lfds700_hash_a_element
47     *hae;
48
49   LFDS700_PAL_ASSERT( baus != NULL );
50   LFDS700_PAL_ASSERT( baue != NULL );
51
52   hae = (struct lfds700_hash_a_element *) LFDS700_BTREE_AU_GET_VALUE_FROM_ELEMENT( *baue );
53   has = (struct lfds700_hash_a_state *) LFDS700_BTREE_AU_GET_USER_STATE_FROM_STATE( *baus );
54
55   has->element_cleanup_callback( has, hae );
56
57   return;
58 }
59
60 #pragma warning( default : 4100 )
61