Ignore:
Timestamp:
Apr 24, 2016, 6:23:14 PM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
51b9c83
Parents:
a35db12
Message:

python/ext: simplify memory allocations, removed unneeded malloc/free calls

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/ext/py-fft.c

    ra35db12 r569b363  
    88  aubio_fft_t * o;
    99  uint_t win_s;
    10   fvec_t *vecin;
     10  // do / rdo input vectors
     11  fvec_t vecin;
     12  cvec_t cvecin;
     13  // do / rdo output results
    1114  cvec_t *out;
     15  fvec_t *rout;
     16  // bridge for cvec output
    1217  Py_cvec *py_out;
    13   cvec_t *cvecin;
    14   fvec_t *rout;
    1518} Py_fft;
    1619
     
    5760  }
    5861
    59   self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
    60   self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
    61 
    6262  self->out = new_cvec(self->win_s);
    6363  self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
     
    7575  del_cvec(self->out);
    7676  del_fvec(self->rout);
    77   free(self->cvecin);
    78   free(self->vecin);
    7977  Py_TYPE(self)->tp_free((PyObject *) self);
    8078}
     
    8987  }
    9088
    91   if (!PyAubio_ArrayToCFvec(input, self->vecin)) {
     89  if (!PyAubio_ArrayToCFvec(input, &(self->vecin))) {
    9290    return NULL;
    9391  }
    9492
    9593  // compute the function
    96   aubio_fft_do (((Py_fft *)self)->o, self->vecin, self->out);
     94  aubio_fft_do (((Py_fft *)self)->o, &(self->vecin), self->out);
    9795#if 0
    9896  Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
     
    120118  }
    121119
    122   if (!PyAubio_ArrayToCCvec (input, self->cvecin) ) {
     120  if (!PyAubio_ArrayToCCvec (input, &(self->cvecin)) ) {
    123121    return NULL;
    124122  }
    125123
    126124  // compute the function
    127   aubio_fft_rdo (self->o, self->cvecin, self->rout);
     125  aubio_fft_rdo (self->o, &(self->cvecin), self->rout);
    128126  return PyAubio_CFvecToArray(self->rout);
    129127}
Note: See TracChangeset for help on using the changeset viewer.