int
fsg_model_word_add(fsg_model_t * fsg, char const *word)
{
    int wid;

    /* Search for an existing word matching this. */
    wid = fsg_model_word_id(fsg, word);
    /* If not found, add this to the vocab. */
    if (wid == -1) {
        wid = fsg->n_word;
        if (fsg->n_word == fsg->n_word_alloc) {
            fsg->n_word_alloc += 10;
            fsg->vocab = ckd_realloc(fsg->vocab,
                                     fsg->n_word_alloc *
                                     sizeof(*fsg->vocab));
            if (fsg->silwords)
                fsg->silwords =
                    bitvec_realloc(fsg->silwords, fsg->n_word_alloc);
            if (fsg->altwords)
                fsg->altwords =
                    bitvec_realloc(fsg->altwords, fsg->n_word_alloc);
        }
        ++fsg->n_word;
        fsg->vocab[wid] = ckd_salloc(word);
    }
    return wid;
}
int
main(int argc, char *argv[])
{
	bitvec_t *bv;
	int i, j;
	clock_t c;

	TEST_ASSERT(bv = bitvec_alloc(199));
	bitvec_set(bv,198);
	bitvec_set(bv,0);
	bitvec_set(bv,42);
	bitvec_set(bv,43);
	bitvec_set(bv,44);
	TEST_ASSERT(bitvec_is_set(bv,198));
	TEST_ASSERT(bitvec_is_set(bv,0));
	TEST_ASSERT(bitvec_is_set(bv,42));
	TEST_ASSERT(bitvec_is_set(bv,43));
	TEST_ASSERT(bitvec_is_set(bv,44));
	TEST_EQUAL(5, bitvec_count_set(bv, 199));
	bitvec_clear(bv, 43);
	TEST_EQUAL(0, bitvec_is_set(bv,43));

	c = clock();
	for (j = 0; j < 1000000; ++j)
		bitvec_count_set(bv, 199);
	c = clock() - c;
	printf("1000000 * 199 bitvec_count_set in %.2f sec\n",
	       (double)c / CLOCKS_PER_SEC);
	bitvec_free(bv);

	bv = bitvec_alloc(1314);
	c = clock();
	for (j = 0; j < 50000; ++j)
		for (i = 0; i < 1314; ++i)
			bitvec_set(bv, i);
	c = clock() - c;
	printf("50000 * 1314 bitvec_set in %.2f sec\n",
	       (double)c / CLOCKS_PER_SEC);
	bitvec_free(bv);

	/* Test realloc */
	bv = bitvec_alloc(13);
	for (i = 1; i < 13; i+=2)
	    bitvec_set(bv, i);
	printf("Bits set %d\n", bitvec_count_set(bv, 13));
        TEST_EQUAL(6, bitvec_count_set(bv, 13));
	bv = bitvec_realloc(bv, 13, 2000);
	for (i = 0; i < 2000; i++) {
          /* printf("%d %d\n", i, bitvec_is_set(bv, i) != 0); */
	}
	printf("Bits set after realloc %d\n", bitvec_count_set(bv, 2000));
        TEST_EQUAL(6, bitvec_count_set(bv, 2000));
	bitvec_free(bv);

	return 0;
}