]> pd.if.org Git - liblfds/blob - liblfds/liblfds7.1.0/test_and_benchmark/libshared/src/libshared_memory/libshared_memory_cleanup.c
Initial import (all versions, including the new 7.1.0)
[liblfds] / liblfds / liblfds7.1.0 / test_and_benchmark / libshared / src / libshared_memory / libshared_memory_cleanup.c
1 /***** includes *****/
2 #include "libshared_memory_internal.h"
3
4
5
6
7
8 /****************************************************************************/
9 void libshared_memory_cleanup( struct libshared_memory_state *ms, void (*memory_cleanup_callback)(enum flag known_numa_node_flag, void *store, lfds710_pal_uint_t size) )
10 {
11   struct lfds710_list_asu_element
12     *lasue,
13     *lasue_next;
14
15   struct libshared_memory_element
16     *me;
17
18   LFDS710_PAL_ASSERT( ms != NULL );
19   // TRD : memory_cleanup_callback can be NULL
20
21   if( memory_cleanup_callback != NULL )
22   {
23     // TRD : remember that the allocation we're free()ing may contain the list element itself
24
25     lasue = LFDS710_LIST_ASU_GET_START( ms->list_of_allocations );
26
27     while( lasue != NULL )
28     {
29       lasue_next = LFDS710_LIST_ASU_GET_NEXT( *lasue );
30       me = LFDS710_LIST_ASU_GET_VALUE_FROM_ELEMENT( *lasue );
31       memory_cleanup_callback( me->known_numa_node_flag, me->original, me->original_memory_size_in_bytes );
32       lasue = lasue_next;
33     }
34   }
35
36   lfds710_list_asu_cleanup( &ms->list_of_allocations, NULL );
37
38   return;
39 }
40