* need to take a size_t ** to carry it along (would all the argument
* overhead be worth it?)
*/
-static size_t correct_deletion(const char *ident, char **array, size_t index) {
+static size_t correct_deletion(const char *ident, char **array) {
size_t itr = 0;
const size_t len = strlen(ident);
char *a = (char*)correct_pool_alloc(len+1);
memcpy(a, ident, itr);
memcpy(a + itr, ident + itr + 1, len - itr);
- array[index + itr] = a;
+ array[itr] = a;
}
return itr;
}
-static size_t correct_transposition(const char *ident, char **array, size_t index) {
+static size_t correct_transposition(const char *ident, char **array) {
size_t itr = 0;
const size_t len = strlen(ident);
tmp = a[itr];
a[itr ] = a[itr+1];
a[itr+1] = tmp;
- array[index + itr] = a;
+ array[itr] = a;
}
return itr;
}
-static size_t correct_alteration(const char *ident, char **array, size_t index) {
+static size_t correct_alteration(const char *ident, char **array) {
size_t itr = 0;
size_t jtr = 0;
size_t ktr = 0;
char *a = (char*)correct_pool_alloc(len+1);
memcpy(a, ident, len+1);
a[itr] = correct_alpha[jtr];
- array[index + ktr] = a;
+ array[ktr] = a;
}
}
return ktr;
}
-static size_t correct_insertion(const char *ident, char **array, size_t index) {
+static size_t correct_insertion(const char *ident, char **array) {
size_t itr = 0;
size_t jtr = 0;
size_t ktr = 0;
memcpy(a, ident, itr);
memcpy(a + itr + 1, ident + itr, len - itr + 1);
a[itr] = correct_alpha[jtr];
- array[index + ktr] = a;
+ array[ktr] = a;
}
}
if (!find)
return NULL;
- next = correct_deletion (ident, find, 0);
- next += correct_transposition(ident, find, next);
- next += correct_alteration (ident, find, next);
- /*****/ correct_insertion (ident, find, next);
+ next = correct_deletion (ident, find);
+ next += correct_transposition(ident, find+next);
+ next += correct_alteration (ident, find+next);
+ /*****/ correct_insertion (ident, find+next);
return find;
}
* cmpl %eax, %ebx ; ebx = &LHS[END_POS]
*
* jbe correct_cmp_eq
- * movb (%edx), %cl ; micro-optimized on even atoms :-)
+ * movb (%edx), %cl ; micro-optimized even on atoms :-)
* cmpb %cl, (%eax) ; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
* jg correct_cmp_gt
* jge correct_cmp_loop
static GMQCC_INLINE char **correct_known_resize(char **res, size_t *allocated, size_t size) {
size_t oldallocated = *allocated;
char **out;
- if (size+1 < oldallocated)
+ if (size < oldallocated)
return res;
out = correct_pool_alloc(sizeof(*res) * oldallocated + 32);
/*
* This is the exposed interface:
* takes a table for the dictonary a vector of sizes (used for internal
- * probability calculation, and an identifier to "correct"
- *
- * the add function works the same. Except the identifier is used to
- * add to the dictonary.
+ * probability calculation), and an identifier to "correct".
*/
char *correct_str(correct_trie_t* table, const char *ident) {
char **e1 = NULL;