Changeset a28dab6


Ignore:
Timestamp:
Apr 18, 2016, 1:18:01 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:
59cb451
Parents:
f2caa92
Message:

python/ext/py-source.c: start fixing memory leak (see #49)

File:
1 edited

Legend:

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

    rf2caa92 ra28dab6  
    99  uint_t channels;
    1010  uint_t hop_size;
     11  fvec_t *read_to;
     12  fmat_t *mread_to;
    1113} Py_source;
    1214
     
    146148  }
    147149
     150  self->read_to = new_fvec(self->hop_size);
     151  self->mread_to = new_fmat (self->channels, self->hop_size);
     152
    148153  return 0;
    149154}
    150155
    151 AUBIO_DEL(source)
     156static void
     157Py_source_del (Py_source *self, PyObject *unused)
     158{
     159  del_aubio_source(self->o);
     160  del_fvec(self->read_to);
     161  del_fmat(self->mread_to);
     162  self->ob_type->tp_free((PyObject *) self);
     163}
     164
    152165
    153166/* function Py_source_do */
     
    158171
    159172  /* output vectors prototypes */
    160   fvec_t* read_to;
    161173  uint_t read;
    162174
     
    167179
    168180  /* creating output read_to as a new_fvec of length self->hop_size */
    169   read_to = new_fvec (self->hop_size);
    170181  read = 0;
    171182
    172183
    173184  /* compute _do function */
    174   aubio_source_do (self->o, read_to, &read);
     185  aubio_source_do (self->o, self->read_to, &read);
    175186
    176187  PyObject *outputs = PyList_New(0);
    177   PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (read_to));
    178   //del_fvec (read_to);
     188  PyList_Append( outputs, (PyObject *)PyAubio_CFvecToArray (self->read_to));
    179189  PyList_Append( outputs, (PyObject *)PyInt_FromLong (read));
    180190  return outputs;
     
    188198
    189199  /* output vectors prototypes */
    190   fmat_t* read_to;
    191200  uint_t read;
    192201
     
    196205
    197206
    198   /* creating output read_to as a new_fvec of length self->hop_size */
    199   read_to = new_fmat (self->channels, self->hop_size);
     207  /* creating output mread_to as a new_fvec of length self->hop_size */
    200208  read = 0;
    201209
    202210
    203211  /* compute _do function */
    204   aubio_source_do_multi (self->o, read_to, &read);
     212  aubio_source_do_multi (self->o, self->mread_to, &read);
    205213
    206214  PyObject *outputs = PyList_New(0);
    207   PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (read_to));
    208   //del_fvec (read_to);
     215  PyList_Append( outputs, (PyObject *)PyAubio_CFmatToArray (self->mread_to));
    209216  PyList_Append( outputs, (PyObject *)PyInt_FromLong (read));
    210217  return outputs;
Note: See TracChangeset for help on using the changeset viewer.