<commit_before>#include "cowboy.h"

VALUE mCowboy;

VALUE fft_1d(VALUE m, VALUE nums){
  fftw_complex *in, *out;
  fftw_plan fp;
  long n;

  Check_Type(nums, T_ARRAY);

  n = size_of_ary(nums);
  if (n == 0){
    rb_raise(rb_eException, "Can't use blank array");
  }
  in = allocate_fftw_complex(n);
  out = allocate_fftw_complex(n);
  fp = fftw_plan_dft_1d(n, in, out, FFTW_FORWARD, FFTW_ESTIMATE);

  cast_nums_to_complex(in, nums);

  fftw_execute(fp);
  free(in);

  return complex_to_real_nums(out, n);
}

void Init_cowboy(){
  mCowboy = rb_define_module("Cowboy");

  Init_cowboy_complex();

  rb_define_module_function(mCowboy, "fft_1d", fft_1d, 1);
}<commit_msg>Reclaim some memory when possible.<commit_after>#include "cowboy.h"

VALUE mCowboy;

VALUE fft_1d(VALUE m, VALUE nums){
  fftw_complex *in, *out;
  fftw_plan fp;
  long n;

  Check_Type(nums, T_ARRAY);

  n = size_of_ary(nums);
  if (n == 0){
    rb_raise(rb_eException, "Can't use blank array");
  }
  in = allocate_fftw_complex(n);
  out = allocate_fftw_complex(n);
  fp = fftw_plan_dft_1d(n, in, out, FFTW_FORWARD, FFTW_ESTIMATE);

  cast_nums_to_complex(in, nums);

  fftw_execute(fp);
  free(in);
  fftw_destroy_plan(fp);

  return complex_to_real_nums(out, n);
}

void Init_cowboy(){
  mCowboy = rb_define_module("Cowboy");

  Init_cowboy_complex();

  rb_define_module_function(mCowboy, "fft_1d", fft_1d, 1);
}
{'fraction_non_alphanumeric': 0.1340057636887608, 'fraction_numerical': 0.008645533141210375, 'mean_word_length': 5.012987012987013, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1159070', 'n_tokens_mistral': 644, 'n_tokens_neox': 619, 'n_words': 113}