******** fig5.8 ********** HASH_TABLE initialize_table( unsigned int table_size ) { HASH_TABLE H; int i; /*1*/ if( table_size < MIN_TABLE_SIZE ) { /*2*/ error("Table size too small"); /*3*/ return NULL; } /*4*/ H = (HASH_TABLE) malloc( sizeof( struct hash_tbl ) ); /* Allocate table */ /*5*/ if( H == NULL ) /*6*/ fatal_error("Out of space!!!"); /*7*/ H->table_size = next_prime( table_size ); /* Allocate list pointers */ /*8*/ H->the_lists = (position *) malloc( sizeof( LIST ) * H->table_size ); /*9*/ if( H->the_lists == NULL ) /*10*/ fatal_error("Out of space!!!"); /*11*/ for(i=0; itable_size; i++ ) /* Allocate list headers */ { /*12*/ H->the_lists[i] = (LIST) malloc( sizeof ( struct list_node ) ); /*13*/ if( H->the_lists[i] == NULL ) /*14*/ fatal_error("Out of space!!!"); else /*15*/ H->the_lists[i]->next = NULL; } /*16*/ return H; }