]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/liblfds710/src/lfds710_hash_addonly/lfds710_hash_addonly_cleanup.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / liblfds710 / src / lfds710_hash_addonly / lfds710_hash_addonly_cleanup.c
1 /***** includes *****/
2 #include "lfds710_hash_addonly_internal.h"
3
4 /***** private prototypes*****/
5 static void btree_au_element_cleanup_function( struct lfds710_btree_au_state *baus,
6                                                struct lfds710_btree_au_element *baue );
7
8
9
10
11
12 /****************************************************************************/
13 void lfds710_hash_a_cleanup( struct lfds710_hash_a_state *has,
14                              void (*element_cleanup_callback)(struct lfds710_hash_a_state *has, struct lfds710_hash_a_element *hae) )
15 {
16   lfds710_pal_uint_t
17     loop;
18
19   LFDS710_PAL_ASSERT( has != NULL );
20   // TRD : element_cleanup_callback can be NULL
21
22   if( element_cleanup_callback == NULL )
23     return;
24
25   LFDS710_MISC_BARRIER_LOAD;
26
27   has->element_cleanup_callback = element_cleanup_callback;
28
29   for( loop = 0 ; loop < has->array_size ; loop++ )
30     lfds710_btree_au_cleanup( has->baus_array+loop, btree_au_element_cleanup_function );
31
32   return;
33 }
34
35
36
37
38
39 /****************************************************************************/
40 #pragma warning( disable : 4100 )
41
42 static void btree_au_element_cleanup_function( struct lfds710_btree_au_state *baus,
43                                                struct lfds710_btree_au_element *baue )
44 {
45   struct lfds710_hash_a_state
46     *has;
47
48   struct lfds710_hash_a_element
49     *hae;
50
51   LFDS710_PAL_ASSERT( baus != NULL );
52   LFDS710_PAL_ASSERT( baue != NULL );
53
54   hae = (struct lfds710_hash_a_element *) LFDS710_BTREE_AU_GET_VALUE_FROM_ELEMENT( *baue );
55   has = (struct lfds710_hash_a_state *) LFDS710_BTREE_AU_GET_USER_STATE_FROM_STATE( *baus );
56
57   has->element_cleanup_callback( has, hae );
58
59   return;
60 }
61
62 #pragma warning( default : 4100 )
63