]> pd.if.org Git - liblfds/blob - liblfds/liblfds6.0.0/liblfds600/src/lfds600_queue/lfds600_queue_delete.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds6.0.0 / liblfds600 / src / lfds600_queue / lfds600_queue_delete.c
1 #include "lfds600_queue_internal.h"
2
3
4
5
6
7 /****************************************************************************/
8 void lfds600_queue_delete( struct lfds600_queue_state *qs, void (*user_data_delete_function)(void *user_data, void *user_state), void *user_state )
9 {
10   void
11     *user_data;
12
13   assert( qs != NULL );
14   // TRD : user_data_delete_function can be NULL
15   // TRD : user_state can be NULL
16
17   while( lfds600_queue_dequeue(qs, &user_data) )
18     if( user_data_delete_function != NULL )
19       user_data_delete_function( user_data, user_state );
20
21   /* TRD : fully dequeuing will leave us
22            with a single dummy element
23            which both qs->enqueue and qs->dequeue point at
24            we push this back onto the lfds600_freelist
25            before we delete the lfds600_freelist
26   */
27
28   lfds600_freelist_push( qs->fs, qs->enqueue[LFDS600_QUEUE_POINTER]->fe );
29
30   lfds600_freelist_delete( qs->fs, lfds600_queue_internal_freelist_delete_function, NULL );
31
32   lfds600_abstraction_aligned_free( qs );
33
34   return;
35 }
36
37
38
39
40
41 /****************************************************************************/
42 #pragma warning( disable : 4100 )
43
44 void lfds600_queue_internal_freelist_delete_function( void *user_data, void *user_state )
45 {
46   assert( user_data != NULL );
47   assert( user_state == NULL );
48
49   lfds600_abstraction_aligned_free( user_data );
50
51   return;
52 }
53
54 #pragma warning( default : 4100 )
55