void test_primes(void) { unsigned int i, j, num; bool success; success = primes_closest(0) > 0; for (num = 1; num < 1024; num++) { if (primes_closest(num) < num) success = FALSE; } for (i = 10; i < 32; i++) { num = (1U << i) - 100; for (j = 0; j < 200; j++, num++) { if (primes_closest(num) < num) success = FALSE; } } test_out("primes_closest()", success); }
struct hash_table * hash_table_create(pool_t table_pool, pool_t node_pool, unsigned int initial_size, hash_callback_t *hash_cb, hash_cmp_callback_t *key_compare_cb) { struct hash_table *table; table = p_new(table_pool, struct hash_table, 1); table->table_pool = table_pool; table->node_pool = node_pool; table->initial_size = I_MAX(primes_closest(initial_size), HASH_TABLE_MIN_SIZE); table->hash_cb = hash_cb != NULL ? hash_cb : direct_hash; table->key_compare_cb = key_compare_cb == NULL ? direct_cmp : key_compare_cb; table->size = table->initial_size; table->nodes = p_new(table_pool, struct hash_node, table->size); return table; }