Changeset 202697a


Ignore:
Timestamp:
Apr 18, 2016, 8:32:07 PM (3 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
de81d2b
Parents:
59cb451
Message:

ext/py-phasevoc.c: continue fixing memory leak (#49)

File:
1 edited

Legend:

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

    r59cb451 r202697a  
    33static char Py_pvoc_doc[] = "pvoc object";
    44
    5 AUBIO_DECLARE(pvoc, uint_t win_s; uint_t hop_s)
     5typedef struct
     6{
     7  PyObject_HEAD
     8  aubio_pvoc_t * o;
     9  uint_t win_s;
     10  uint_t hop_s;
     11  cvec_t *output;
     12  fvec_t *routput;
     13} Py_pvoc;
     14
    615
    716//AUBIO_NEW(pvoc)
     
    4756  }
    4857
     58  self->output = new_cvec(self->win_s);
     59  self->routput = new_fvec(self->hop_s);
     60
    4961  return (PyObject *) self;
    5062}
     
    5365AUBIO_INIT(pvoc, self->win_s, self->hop_s)
    5466
    55 AUBIO_DEL(pvoc)
     67static void
     68Py_pvoc_del (Py_pvoc *self, PyObject *unused)
     69{
     70  del_aubio_pvoc(self->o);
     71  del_cvec(self->output);
     72  del_fvec(self->routput);
     73  self->ob_type->tp_free((PyObject *) self);
     74}
     75
    5676
    5777static PyObject *
     
    6080  PyObject *input;
    6181  fvec_t *vec;
    62   cvec_t *output;
    6382
    6483  if (!PyArg_ParseTuple (args, "O", &input)) {
     
    7291  }
    7392
    74   output = new_cvec(self->win_s);
    75 
    7693  // compute the function
    77   aubio_pvoc_do (self->o, vec, output);
    78   return (PyObject *)PyAubio_CCvecToPyCvec(output);
     94  aubio_pvoc_do (self->o, vec, self->output);
     95  return (PyObject *)PyAubio_CCvecToPyCvec(self->output);
    7996}
    8097
     
    91108  PyObject *input;
    92109  cvec_t *vec;
    93   fvec_t *output;
    94 
    95110  if (!PyArg_ParseTuple (args, "O", &input)) {
    96111    return NULL;
     
    103118  }
    104119
    105   output = new_fvec(self->hop_s);
    106 
    107120  // compute the function
    108   aubio_pvoc_rdo (self->o, vec, output);
    109   return (PyObject *)PyAubio_CFvecToArray(output);
     121  aubio_pvoc_rdo (self->o, vec, self->routput);
     122  return (PyObject *)PyAubio_CFvecToArray(self->routput);
    110123}
    111124
Note: See TracChangeset for help on using the changeset viewer.