| 91 | } |
| 92 | |
| 93 | static void ps_map_rehash( struct ps_map * map ) |
| 94 | { |
| 95 | struct ps_map old = *map; |
| 96 | int32_t i; |
| 97 | map->table = (struct ps_map_entry * *)BJAM_MALLOC( size_t(map->table_size) * 2 * sizeof( struct ps_map_entry * ) ); |
| 98 | map->table_size *= 2; |
| 99 | for ( i = 0; i < map->table_size; ++i ) |
| 100 | { |
| 101 | map->table[ i ] = NULL; |
| 102 | } |
| 103 | for ( i = 0; i < old.table_size; ++i ) |
| 104 | { |
| 105 | struct ps_map_entry * pos; |
| 106 | for ( pos = old.table[ i ]; pos; ) |
| 107 | { |
| 108 | struct ps_map_entry * tmp = pos->next; |
| 109 | |
| 110 | unsigned hash_val = list_hash( pos->key ); |
| 111 | unsigned bucket = hash_val % map->table_size; |
| 112 | pos->next = map->table[ bucket ]; |
| 113 | map->table[ bucket ] = pos; |
| 114 | |
| 115 | pos = tmp; |
| 116 | } |
| 117 | } |
| 118 | BJAM_FREE( old.table ); |
| 119 | } |
| 120 | |
| 121 | static struct ps_map_entry * ps_map_insert(struct ps_map * map, LIST * key) |
| 122 | { |
no test coverage detected