Ticket #7093: lists.patch
File lists.patch, 2.1 KB (added by , 10 years ago) |
---|
-
tools/build/v2/engine/lists.c
13 13 14 14 #include <assert.h> 15 15 16 static LIST * freelist[ 32 ]; /* junkpile for list_dealloc() */ 16 17 17 struct freelist_node { struct freelist_node * next; };18 19 static struct freelist_node * freelist[ 32 ]; /* junkpile for list_dealloc() */20 21 18 static unsigned get_bucket( unsigned size ) 22 19 { 23 20 unsigned bucket = 0; … … 30 27 unsigned const bucket = get_bucket( size ); 31 28 if ( freelist[ bucket ] ) 32 29 { 33 struct freelist_node* result = freelist[ bucket ];34 freelist[ bucket ] = result-> next;35 return (LIST *)result;30 LIST * result = freelist[ bucket ]; 31 freelist[ bucket ] = result->impl.next; 32 return result; 36 33 } 37 34 return (LIST *)BJAM_MALLOC( sizeof( LIST ) + ( 1u << bucket ) * 38 35 sizeof( OBJECT * ) ); … … 42 39 { 43 40 unsigned size = list_length( l ); 44 41 unsigned bucket; 45 struct freelist_node * node = (struct freelist_node *)l;42 LIST * node = l; 46 43 47 44 if ( size == 0 ) return; 48 45 … … 51 48 #ifdef BJAM_NO_MEM_CACHE 52 49 BJAM_FREE( node ); 53 50 #else 54 node-> next = freelist[ bucket ];51 node->impl.next = freelist[ bucket ]; 55 52 freelist[ bucket ] = node; 56 53 #endif 57 54 } … … 372 369 int i; 373 370 for ( i = 0; i < sizeof( freelist ) / sizeof( freelist[ 0 ] ); ++i ) 374 371 { 375 struct freelist_node* l = freelist[ i ];372 LIST * l = freelist[ i ]; 376 373 while ( l ) 377 374 { 378 struct freelist_node* const tmp = l;379 l = l-> next;375 LIST * const tmp = l; 376 l = l->impl.next; 380 377 BJAM_FREE( tmp ); 381 378 } 382 379 } -
tools/build/v2/engine/lists.h
54 54 typedef struct _list { 55 55 union { 56 56 int size; 57 struct _list * next; 57 58 OBJECT * align; 58 59 } impl; 59 60 } LIST;