History

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

Paul Brossier committed 10 years ago

Commit 7c785e61 parent de81d2b1 file · +10 −4Browse files

Showing the changes to python/ext (1 of 1 file). Show all

Unified · Split

python/ext/py-filter.c+10−4
@@ -5,6 +5,7 @@ typedef struct · 4 unmodified lines
5 PyObject_HEAD5 PyObject_HEAD
6 aubio_filter_t * o;6 aubio_filter_t * o;
7 uint_t order;7 uint_t order;
8 fvec_t *out;
8} Py_filter;9} Py_filter;
9 10
10static char Py_filter_doc[] = "filter object";11static char Py_filter_doc[] = "filter object";
@@ -47,13 +48,14 @@ Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds) · 36 unmodified lines
47 if (self->o == NULL) {48 if (self->o == NULL) {
48 return -1;49 return -1;
49 }50 }
50 51 self->out = new_fvec(Py_default_vector_length);
51 return 0;52 return 0;
52}53}
53 54
54static void55static void
55Py_filter_del (Py_filter * self)56Py_filter_del (Py_filter * self)
56{57{
58 del_fvec(self->out);
57 del_aubio_filter (self->o);59 del_aubio_filter (self->o);
58 self->ob_type->tp_free ((PyObject *) self);60 self->ob_type->tp_free ((PyObject *) self);
59}61}
@@ -78,10 +80,14 @@ Py_filter_do(Py_filter * self, PyObject * args) · 18 unmodified lines
78 return NULL;80 return NULL;
79 }81 }
80 82
83 // reallocate the output if needed
84 if (vec->length != self->out->length) {
85 del_fvec(self->out);
86 self->out = new_fvec(vec->length);
87 }
81 // compute the function88 // compute the function
82 fvec_t * out = new_fvec(vec->length);89 aubio_filter_do_outplace (self->o, vec, self->out);
83 aubio_filter_do_outplace (self->o, vec, out);90 return PyAubio_CFvecToArray(self->out);
84 return PyAubio_CFvecToArray(out);
85}91}
86 92
87static PyObject * 93static PyObject *

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t