Ticket #7093: lists.patch

File lists.patch, 2.1 KB (added by Steven Watanabe, 10 years ago)

One more attempt

  • tools/build/v2/engine/lists.c

     
    1313
    1414#include <assert.h>
    1515
     16static LIST * freelist[ 32 ];  /* junkpile for list_dealloc() */
    1617
    17 struct freelist_node { struct freelist_node * next; };
    18 
    19 static struct freelist_node * freelist[ 32 ];  /* junkpile for list_dealloc() */
    20 
    2118static unsigned get_bucket( unsigned size )
    2219{
    2320    unsigned bucket = 0;
     
    3027    unsigned const bucket = get_bucket( size );
    3128    if ( freelist[ bucket ] )
    3229    {
    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;
    3633    }
    3734    return (LIST *)BJAM_MALLOC( sizeof( LIST ) + ( 1u << bucket ) *
    3835        sizeof( OBJECT * ) );
     
    4239{
    4340    unsigned size = list_length( l );
    4441    unsigned bucket;
    45     struct freelist_node * node = (struct freelist_node *)l;
     42    LIST * node = l;
    4643
    4744    if ( size == 0 ) return;
    4845
     
    5148#ifdef BJAM_NO_MEM_CACHE
    5249    BJAM_FREE( node );
    5350#else
    54     node->next = freelist[ bucket ];
     51    node->impl.next = freelist[ bucket ];
    5552    freelist[ bucket ] = node;
    5653#endif
    5754}
     
    372369    int i;
    373370    for ( i = 0; i < sizeof( freelist ) / sizeof( freelist[ 0 ] ); ++i )
    374371    {
    375         struct freelist_node * l = freelist[ i ];
     372        LIST * l = freelist[ i ];
    376373        while ( l )
    377374        {
    378             struct freelist_node * const tmp = l;
    379             l = l->next;
     375            LIST * const tmp = l;
     376            l = l->impl.next;
    380377            BJAM_FREE( tmp );
    381378        }
    382379    }
  • tools/build/v2/engine/lists.h

     
    5454typedef struct _list {
    5555    union {
    5656        int size;
     57        struct _list * next;
    5758        OBJECT * align;
    5859    } impl;
    5960} LIST;