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-phasevoc.c

    ra35db12 r569b363  
    11#include "aubio-types.h"
    2 
    3 static char Py_pvoc_doc[] = "pvoc object";
    42
    53typedef struct
     
    97  uint_t win_s;
    108  uint_t hop_s;
    11   fvec_t *vecin;
     9  fvec_t vecin;
    1210  cvec_t *output;
    1311  Py_cvec *py_out;
    14   cvec_t *cvecin;
     12  cvec_t cvecin;
    1513  fvec_t *routput;
    1614} Py_pvoc;
     
    7270  }
    7371
    74   self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
    75   self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
    76 
    7772  self->output = new_cvec(self->win_s);
    7873  self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
     
    8984  del_cvec(self->output);
    9085  del_fvec(self->routput);
    91   free(self->cvecin);
    92   free(self->vecin);
    9386  Py_TYPE(self)->tp_free((PyObject *) self);
    9487}
     
    10497  }
    10598
    106   if (!PyAubio_ArrayToCFvec (input, self->vecin)) {
     99  if (!PyAubio_ArrayToCFvec (input, &(self->vecin) )) {
    107100    return NULL;
    108101  }
    109102
    110103  // compute the function
    111   aubio_pvoc_do (self->o, self->vecin, self->output);
     104  aubio_pvoc_do (self->o, &(self->vecin), self->output);
    112105#if 0
    113106  Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
     
    136129  }
    137130
    138   if (!PyAubio_ArrayToCCvec (input, self->cvecin)) {
     131  if (!PyAubio_ArrayToCCvec (input, &(self->cvecin) )) {
    139132    return NULL;
    140133  }
    141134
    142135  // compute the function
    143   aubio_pvoc_rdo (self->o, self->cvecin, self->routput);
     136  aubio_pvoc_rdo (self->o, &(self->cvecin), self->routput);
    144137  return PyAubio_CFvecToArray(self->routput);
    145138}
Note: See TracChangeset for help on using the changeset viewer.