diff --git a/src/engine/lists.c b/src/engine/lists.c index 7e3b4a3f0..3f2309b05 100644 --- a/src/engine/lists.c +++ b/src/engine/lists.c @@ -13,10 +13,7 @@ #include - -struct freelist_node { struct freelist_node * next; }; - -static struct freelist_node * freelist[ 32 ]; /* junkpile for list_dealloc() */ +static LIST * freelist[ 32 ]; /* junkpile for list_dealloc() */ static unsigned get_bucket( unsigned size ) { @@ -30,9 +27,9 @@ static LIST * list_alloc( unsigned const size ) unsigned const bucket = get_bucket( size ); if ( freelist[ bucket ] ) { - struct freelist_node * result = freelist[ bucket ]; - freelist[ bucket ] = result->next; - return (LIST *)result; + LIST * result = freelist[ bucket ]; + freelist[ bucket ] = result->impl.next; + return result; } return (LIST *)BJAM_MALLOC( sizeof( LIST ) + ( 1u << bucket ) * sizeof( OBJECT * ) ); @@ -42,7 +39,7 @@ static void list_dealloc( LIST * l ) { unsigned size = list_length( l ); unsigned bucket; - struct freelist_node * node = (struct freelist_node *)l; + LIST * node = l; if ( size == 0 ) return; @@ -51,7 +48,7 @@ static void list_dealloc( LIST * l ) #ifdef BJAM_NO_MEM_CACHE BJAM_FREE( node ); #else - node->next = freelist[ bucket ]; + node->impl.next = freelist[ bucket ]; freelist[ bucket ] = node; #endif } @@ -372,11 +369,11 @@ void list_done() int i; for ( i = 0; i < sizeof( freelist ) / sizeof( freelist[ 0 ] ); ++i ) { - struct freelist_node * l = freelist[ i ]; + LIST * l = freelist[ i ]; while ( l ) { - struct freelist_node * const tmp = l; - l = l->next; + LIST * const tmp = l; + l = l->impl.next; BJAM_FREE( tmp ); } } diff --git a/src/engine/lists.h b/src/engine/lists.h index 0b958303d..3dd8fe873 100644 --- a/src/engine/lists.h +++ b/src/engine/lists.h @@ -54,6 +54,7 @@ typedef struct _list { union { int size; + struct _list * next; OBJECT * align; } impl; } LIST;