static char *correct(char *word)
{
        char **e1, **e2, *e1_word, *e2_word, *res_word = word;
        int e1_rows, e2_rows;
        
        if (find(word))
                return word;
        
        e1_rows = edits1_rows(word);
        if (e1_rows) {
                e1      = edits1(word);
                e1_word = max(e1, e1_rows);

                if (e1_word) {
                        array_cleanup(e1, e1_rows);
                        free(e1);
                        return e1_word;
                }
        }

        e2 = known_edits2(e1, e1_rows, &e2_rows);
        if (e2_rows) {
                e2_word = max(e2, e2_rows);
                if (e2_word)
                        res_word = e2_word;
        }
        
        array_cleanup(e1, e1_rows);
        array_cleanup(e2, e2_rows);
        
        free(e1);
        free(e2);
        
        return res_word;
}
Beispiel #2
0
static
void
commandline_macros_cleanup(void)
{
	unsigned i, num;
	struct commandline_macro *cm;

	num = array_num(&commandline_macros);
	for (i=0; i<num; i++) {
		cm = array_get(&commandline_macros, i);
		dofree(cm, sizeof(*cm));
	}
	array_setsize(&commandline_macros, 0);
	
	array_cleanup(&commandline_macros);
}
Beispiel #3
0
static
void
commandline_files_cleanup(void)
{
	unsigned i, num;
	struct commandline_file *cf;

	num = array_num(&commandline_files);
	for (i=0; i<num; i++) {
		cf = array_get(&commandline_files, i);
		if (cf != NULL) {
			dofree(cf, sizeof(*cf));
		}
	}
	array_setsize(&commandline_files, 0);

	array_cleanup(&commandline_files);
}
Beispiel #4
0
void
array_destroy(struct array *a)
{
	array_cleanup(a);
	kfree(a);
}