Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 0.88 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. // Some things that were defined before...for dealing with perl things...long story
  2.  
  3. #define META_MALLOC(v,n,t) (v = (t*)malloc(((n)*sizeof(t))))
  4. #define META_REALLOC(v,n,t) (v = (t*)realloc((v),((n)*sizeof(t))))
  5. #define META_FREE(x) free((x))
  6.  
  7.  
  8. // 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.
  9. void
  10. DoubleMetaphone(char *str, char **codes);
  11.        
  12. // Little struct I made
  13. struct dm_result {
  14.     char * primary;
  15.     char * secondary;
  16. };
  17.  
  18. // Cleanup the struct
  19. void
  20. free_dm_result(struct dm_result * result) {
  21.     META_FREE(result->primary);
  22.     META_FREE(result->secondary);
  23.     META_FREE(result);
  24. }
  25.  
  26. // Helper/wrapper function
  27. struct dm_result *
  28. double_metaphone(char * input) {
  29.     struct dm_result * result;
  30.     META_MALLOC(result, 1, struct dm_result);
  31.     DoubleMetaphone(input, (char **) result);
  32.     return result;
  33. }