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
55 PyObject_HEAD
66 aubio_filter_t * o;
77 uint_t order;
8+ fvec_t *out;
89 } Py_filter;
910
1011 static char Py_filter_doc[] = "filter object";
@@ -47,13 +48,14 @@ Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds) · 36 unmodified lines
4748 if (self->o == NULL) {
4849 return -1;
4950 }
50−
51+ self->out = new_fvec(Py_default_vector_length);
5152 return 0;
5253 }
5354
5455 static void
5556 Py_filter_del (Py_filter * self)
5657 {
58+ del_fvec(self->out);
5759 del_aubio_filter (self->o);
5860 self->ob_type->tp_free ((PyObject *) self);
5961 }
@@ -78,10 +80,14 @@ Py_filter_do(Py_filter * self, PyObject * args) · 18 unmodified lines
7880 return NULL;
7981 }
8082
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+ }
8188 // compute the function
82− fvec_t * out = new_fvec(vec->length);
83− aubio_filter_do_outplace (self->o, vec, out);
84− return PyAubio_CFvecToArray(out);
89+ aubio_filter_do_outplace (self->o, vec, self->out);
90+ return PyAubio_CFvecToArray(self->out);
8591 }
8692
8793 static 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