
Untitled
By: a guest on
Apr 29th, 2012 | syntax:
None | size: 0.88 KB | hits: 14 | expires: Never
// Some things that were defined before...for dealing with perl things...long story
#define META_MALLOC(v,n,t) (v = (t*)malloc(((n)*sizeof(t))))
#define META_REALLOC(v,n,t) (v = (t*)realloc((v),((n)*sizeof(t))))
#define META_FREE(x) free((x))
// The function that appears later in the file that I need to call. Sets a primary and secondary code, so codes is only two items.
void
DoubleMetaphone(char *str, char **codes);
// Little struct I made
struct dm_result {
char * primary;
char * secondary;
};
// Cleanup the struct
void
free_dm_result(struct dm_result * result) {
META_FREE(result->primary);
META_FREE(result->secondary);
META_FREE(result);
}
// Helper/wrapper function
struct dm_result *
double_metaphone(char * input) {
struct dm_result * result;
META_MALLOC(result, 1, struct dm_result);
DoubleMetaphone(input, (char **) result);
return result;
}