2 #include "lfds710_ringbuffer_internal.h"
4 /***** private prototypes *****/
5 static void lfds710_ringbuffer_internal_queue_umm_element_cleanup_callback( struct lfds710_queue_umm_state *qumms,
6 struct lfds710_queue_umm_element *qumme,
7 enum lfds710_misc_flag dummy_element_flag );
8 static void lfds710_ringbuffer_internal_freelist_element_cleanup_callback( struct lfds710_freelist_state *fs,
9 struct lfds710_freelist_element *fe );
15 /****************************************************************************/
16 void lfds710_ringbuffer_cleanup( struct lfds710_ringbuffer_state *rs,
17 void (*element_cleanup_callback)(struct lfds710_ringbuffer_state *rs, void *key, void *value, enum lfds710_misc_flag unread_flag) )
19 LFDS710_PAL_ASSERT( rs != NULL );
20 // TRD : element_cleanup_callback can be NULL
22 if( element_cleanup_callback != NULL )
24 rs->element_cleanup_callback = element_cleanup_callback;
25 lfds710_queue_umm_cleanup( &rs->qumms, lfds710_ringbuffer_internal_queue_umm_element_cleanup_callback );
26 lfds710_freelist_cleanup( &rs->fs, lfds710_ringbuffer_internal_freelist_element_cleanup_callback );
36 /****************************************************************************/
37 #pragma warning( disable : 4100 )
39 static void lfds710_ringbuffer_internal_queue_umm_element_cleanup_callback( struct lfds710_queue_umm_state *qumms,
40 struct lfds710_queue_umm_element *qumme,
41 enum lfds710_misc_flag dummy_element_flag )
43 struct lfds710_ringbuffer_element
46 struct lfds710_ringbuffer_state
49 LFDS710_PAL_ASSERT( qumms != NULL );
50 LFDS710_PAL_ASSERT( qumme != NULL );
51 // TRD : dummy_element can be any value in its range
53 rs = (struct lfds710_ringbuffer_state *) LFDS710_QUEUE_UMM_GET_USER_STATE_FROM_STATE( *qumms );
54 re = (struct lfds710_ringbuffer_element *) LFDS710_QUEUE_UMM_GET_VALUE_FROM_ELEMENT( *qumme );
56 if( dummy_element_flag == LFDS710_MISC_FLAG_LOWERED )
57 rs->element_cleanup_callback( rs, re->key, re->value, LFDS710_MISC_FLAG_RAISED );
62 #pragma warning( default : 4100 )
68 /****************************************************************************/
69 #pragma warning( disable : 4100 )
71 static void lfds710_ringbuffer_internal_freelist_element_cleanup_callback( struct lfds710_freelist_state *fs,
72 struct lfds710_freelist_element *fe )
74 struct lfds710_ringbuffer_element
77 struct lfds710_ringbuffer_state
80 LFDS710_PAL_ASSERT( fs != NULL );
81 LFDS710_PAL_ASSERT( fe != NULL );
83 rs = (struct lfds710_ringbuffer_state *) LFDS710_FREELIST_GET_USER_STATE_FROM_STATE( *fs );
84 re = (struct lfds710_ringbuffer_element *) LFDS710_FREELIST_GET_VALUE_FROM_ELEMENT( *fe );
86 rs->element_cleanup_callback( rs, re->key, re->value, LFDS710_MISC_FLAG_LOWERED );
91 #pragma warning( default : 4100 )