Sunday, 13 May 2012

Malloc - Incorrect Checksum for Freed Object


hi all,

still working on same project, have error never had before.

code:
  complex* fft(complex* x)  {      int n = sizeof(x)/sizeof(double);      complex *w_out;      w_out = (complex*) calloc(sizeof(complex), n);                  fftw_complex *in, *out;      in = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n);      out = (fftw_complex*) fftw_malloc(sizeof(fftw_complex) * n);            fftw_plan p;            (int j = 0; j < n; j++)      {          in[j][0] = x[j].getreal();          in[j][1] = x[j].getimaginary();      }            p = fftw_plan_dft_1d(n, in, out, fftw_forward, fftw_estimate);            fftw_execute(p);            (int = 0; < n; i++)      {          w_out[i].setreal(out[i][0]);          w_out[i].setimaginary(out[i][1]);                }      fftw_destroy_plan(p);      fftw_free(in); fftw_free(out);            return w_out;  }  
above call fast fourier transform, adapted program (cf. previous thread complex class) , based on fftw3 libraries.

further in program, call function several times.
1 time in function called fftmethod , 2 other times frfftmethod.
if call straight forward
code:
 y = fft(x); 
, works fine fftmethod. returns me weird looking malloc error frfftmethod comes fftw_free commands.
of course when try remove commands, segmentation fault error.

if guys have idea of might wrong, i'm pretty stuck here.

d.


ps: have reasonable doubt concerning declaration of int n in fft function, didn't seem problem before.
 

shame on me.

looks didn't kind of definition.

bad useless post!

newbie inside, bear me ;)
 


Forums Macs Mac Programming


  • iPhone
  • Mac OS & System Software
  • iPad
  • Apple Watch
  • Notebooks
  • iTunes
  • Apple ID
  • iCloud
  • Desktop Computers
  • Apple Music
  • Professional Applications
  • iPod
  • iWork
  • Apple TV
  • iLife
  • Wireless

No comments:

Post a Comment