History

python/ext: simplify memory allocations, removed unneeded malloc/free calls

Paul Brossier committed 10 years ago

Commit 569b3631 parent a35db129 files · +75 −125Browse files

Showing the changes to python (9 of 9 files). Show all

Unified · Split

9 files
  1. python/ext/aubiomodule.c +10 −18
  2. python/ext/aubioproxy.c +7 −9
  3. python/ext/py-fft.c +10 −12
  4. python/ext/py-filter.c +5 −7
  5. python/ext/py-filterbank.c +10 −21
  6. python/ext/py-musicutils.c +12 −24
  7. python/ext/py-phasevoc.c +6 −13
  8. python/ext/py-sink.c +7 −13
  9. python/lib/gen_code.py +8 −8
python/ext/aubiomodule.c+10−18
@@ -83,7 +83,7 @@ static PyObject * · 82 unmodified lines
8383 Py_alpha_norm (PyObject * self, PyObject * args)
8484 {
8585 PyObject *input;
86− fvec_t *vec;
86+ fvec_t vec;
8787 smpl_t alpha;
8888 PyObject *result;
8989
@@ -95,15 +95,12 @@ Py_alpha_norm (PyObject * self, PyObject * args) · 5 unmodified lines
9595 return NULL;
9696 }
9797
98− vec = (fvec_t *)malloc(sizeof(fvec_t));
99− if (!PyAubio_ArrayToCFvec(input, vec)) {
100− free(vec);
98+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
10199 return NULL;
102100 }
103101
104102 // compute the function
105− result = Py_BuildValue ("f", fvec_alpha_norm (vec, alpha));
106− free(vec);
103+ result = Py_BuildValue ("f", fvec_alpha_norm (&vec, alpha));
107104 if (result == NULL) {
108105 return NULL;
109106 }
@@ -175,7 +172,7 @@ static PyObject * · 65 unmodified lines
175172 Py_zero_crossing_rate (PyObject * self, PyObject * args)
176173 {
177174 PyObject *input;
178− fvec_t *vec;
175+ fvec_t vec;
179176 PyObject *result;
180177
181178 if (!PyArg_ParseTuple (args, "O:zero_crossing_rate", &input)) {
@@ -186,15 +183,12 @@ Py_zero_crossing_rate (PyObject * self, PyObject * args) · 4 unmodified lines
186183 return NULL;
187184 }
188185
189− vec = (fvec_t *)malloc(sizeof(fvec_t));
190− if (!PyAubio_ArrayToCFvec(input, vec)) {
191− free(vec);
186+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
192187 return NULL;
193188 }
194189
195190 // compute the function
196− result = Py_BuildValue ("f", aubio_zero_crossing_rate (vec));
197− free(vec);
191+ result = Py_BuildValue ("f", aubio_zero_crossing_rate (&vec));
198192 if (result == NULL) {
199193 return NULL;
200194 }
@@ -206,7 +200,7 @@ static PyObject * · 5 unmodified lines
206200 Py_min_removal(PyObject * self, PyObject * args)
207201 {
208202 PyObject *input;
209− fvec_t *vec;
203+ fvec_t vec;
210204
211205 if (!PyArg_ParseTuple (args, "O:min_removal", &input)) {
212206 return NULL;
@@ -216,19 +210,17 @@ Py_min_removal(PyObject * self, PyObject * args) · 3 unmodified lines
216210 return NULL;
217211 }
218212
219− vec = (fvec_t *)malloc(sizeof(fvec_t));
220− if (!PyAubio_ArrayToCFvec(input, vec)) {
221− free(vec);
213+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
222214 return NULL;
223215 }
224216
225217 // compute the function
226− fvec_min_removal (vec);
218+ fvec_min_removal (&vec);
227219
228220 // since this function does not return, we could return None
229221 //Py_RETURN_NONE;
230222 // however it is convenient to return the modified vector
231− return (PyObject *) PyAubio_CFvecToArray(vec);
223+ return (PyObject *) PyAubio_CFvecToArray(&vec);
232224 // or even without converting it back to an array
233225 //Py_INCREF(vec);
234226 //return (PyObject *)vec;
python/ext/aubioproxy.c+7−9
@@ -143,17 +143,15 @@ PyAubio_ArrayToCFmat (PyObject *input, fmat_t *mat) { · 142 unmodified lines
143143 return 0;
144144 }
145145
146− if (mat->height != (uint_t)PyArray_DIM ((PyArrayObject *)input, 0)) {
147− /*
148− free(mat->data);
149− mat->height = (uint_t)PyArray_DIM ((PyArrayObject *)input, 0);
150− mat->data = (smpl_t **)malloc(sizeof(smpl_t*) * mat->height);
151− */
152− PyErr_Format(PyExc_ValueError, "too many rows, %d but %ld expected",
153− mat->height, PyArray_DIM ((PyArrayObject *)input, 0) );
154− return 0;
146+ uint_t new_height = (uint_t)PyArray_DIM ((PyArrayObject *)input, 0);
147+ if (mat->height != new_height) {
148+ if (mat->data) {
149+ free(mat->data);
150+ }
151+ mat->data = (smpl_t **)malloc(sizeof(smpl_t*) * new_height);
155152 }
156153
154+ mat->height = new_height;
157155 mat->length = (uint_t)PyArray_DIM ((PyArrayObject *)input, 1);
158156 for (i=0; i< mat->height; i++) {
159157 mat->data[i] = (smpl_t*)PyArray_GETPTR1 ((PyArrayObject *)input, i);
python/ext/py-fft.c+10−12
@@ -7,11 +7,14 @@ typedef struct · 6 unmodified lines
77 PyObject_HEAD
88 aubio_fft_t * o;
99 uint_t win_s;
10− fvec_t *vecin;
10+ // do / rdo input vectors
11+ fvec_t vecin;
12+ cvec_t cvecin;
13+ // do / rdo output results
1114 cvec_t *out;
12− Py_cvec *py_out;
13− cvec_t *cvecin;
1415 fvec_t *rout;
16+ // bridge for cvec output
17+ Py_cvec *py_out;
1518 } Py_fft;
1619
1720 static PyObject *
@@ -56,9 +59,6 @@ Py_fft_init (Py_fft * self, PyObject * args, PyObject * kwds) · 38 unmodified lines
5659 return -1;
5760 }
5861
59− self->cvecin = (cvec_t *)malloc(sizeof(cvec_t));
60− self->vecin = (fvec_t *)malloc(sizeof(fvec_t));
61−
6262 self->out = new_cvec(self->win_s);
6363 self->py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
6464 Py_XINCREF(self->py_out);
@@ -74,8 +74,6 @@ Py_fft_del (Py_fft *self, PyObject *unused) · 9 unmodified lines
7474 del_aubio_fft(self->o);
7575 del_cvec(self->out);
7676 del_fvec(self->rout);
77− free(self->cvecin);
78− free(self->vecin);
7977 Py_TYPE(self)->tp_free((PyObject *) self);
8078 }
8179
@@ -88,12 +86,12 @@ Py_fft_do(Py_fft * self, PyObject * args) · 6 unmodified lines
8886 return NULL;
8987 }
9088
91− if (!PyAubio_ArrayToCFvec(input, self->vecin)) {
89+ if (!PyAubio_ArrayToCFvec(input, &(self->vecin))) {
9290 return NULL;
9391 }
9492
9593 // compute the function
96− aubio_fft_do (((Py_fft *)self)->o, self->vecin, self->out);
94+ aubio_fft_do (((Py_fft *)self)->o, &(self->vecin), self->out);
9795 #if 0
9896 Py_cvec * py_out = (Py_cvec*) PyObject_New (Py_cvec, &Py_cvecType);
9997 PyObject* output = PyAubio_CCvecToPyCvec(self->out, py_out);
@@ -119,12 +117,12 @@ Py_fft_rdo(Py_fft * self, PyObject * args) · 19 unmodified lines
119117 return NULL;
120118 }
121119
122− if (!PyAubio_ArrayToCCvec (input, self->cvecin) ) {
120+ if (!PyAubio_ArrayToCCvec (input, &(self->cvecin)) ) {
123121 return NULL;
124122 }
125123
126124 // compute the function
127− aubio_fft_rdo (self->o, self->cvecin, self->rout);
125+ aubio_fft_rdo (self->o, &(self->cvecin), self->rout);
128126 return PyAubio_CFvecToArray(self->rout);
129127 }
130128
python/ext/py-filter.c+5−7
@@ -5,7 +5,7 @@ typedef struct · 4 unmodified lines
55 PyObject_HEAD
66 aubio_filter_t * o;
77 uint_t order;
8− fvec_t *vec;
8+ fvec_t vec;
99 fvec_t *out;
1010 } Py_filter;
1111
@@ -50,7 +50,6 @@ Py_filter_init (Py_filter * self, PyObject * args, PyObject * kwds) · 38 unmodified lines
5050 return -1;
5151 }
5252 self->out = new_fvec(Py_default_vector_length);
53− self->vec = (fvec_t *)malloc(sizeof(fvec_t));
5453 return 0;
5554 }
5655
@@ -59,7 +58,6 @@ Py_filter_del (Py_filter * self) · 2 unmodified lines
5958 {
6059 del_fvec(self->out);
6160 del_aubio_filter (self->o);
62− free(self->vec);
6361 Py_TYPE(self)->tp_free ((PyObject *) self);
6462 }
6563
@@ -76,17 +74,17 @@ Py_filter_do(Py_filter * self, PyObject * args) · 10 unmodified lines
7674 return NULL;
7775 }
7876
79− if (!PyAubio_ArrayToCFvec(input, self->vec)) {
77+ if (!PyAubio_ArrayToCFvec(input, &(self->vec))) {
8078 return NULL;
8179 }
8280
8381 // reallocate the output if needed
84− if (self->vec->length != self->out->length) {
82+ if (self->vec.length != self->out->length) {
8583 del_fvec(self->out);
86− self->out = new_fvec(self->vec->length);
84+ self->out = new_fvec(self->vec.length);
8785 }
8886 // compute the function
89− aubio_filter_do_outplace (self->o, self->vec, self->out);
87+ aubio_filter_do_outplace (self->o, &(self->vec), self->out);
9088 return PyAubio_CFvecToArray(self->out);
9189 }
9290
python/ext/py-filterbank.c+10−21
@@ -8,10 +8,10 @@ typedef struct · 7 unmodified lines
88 aubio_filterbank_t * o;
99 uint_t n_filters;
1010 uint_t win_s;
11− cvec_t *vec;
11+ cvec_t vec;
12+ fvec_t freqs;
13+ fmat_t coeffs;
1214 fvec_t *out;
13− fvec_t *freqs;
14− fmat_t *coeffs;
1515 } Py_filterbank;
1616
1717 static PyObject *
@@ -66,14 +66,6 @@ Py_filterbank_init (Py_filterbank * self, PyObject * args, PyObject * kwds) · 48 unmodified lines
6666 }
6767 self->out = new_fvec(self->n_filters);
6868
69− self->vec = (cvec_t *)malloc(sizeof(cvec_t));
70−
71− self->freqs = (fvec_t *)malloc(sizeof(fvec_t));
72−
73− self->coeffs = (fmat_t *)malloc(sizeof(fmat_t));
74− self->coeffs->data = (smpl_t **)malloc(sizeof(smpl_t*) * self->n_filters);
75− self->coeffs->height = self->n_filters;
76−
7769 return 0;
7870 }
7971
@@ -82,10 +74,7 @@ Py_filterbank_del (Py_filterbank *self, PyObject *unused) · 2 unmodified lines
8274 {
8375 del_aubio_filterbank(self->o);
8476 del_fvec(self->out);
85− free(self->vec);
86− free(self->freqs);
87− free(self->coeffs->data);
88− free(self->coeffs);
77+ free(self->coeffs.data);
8978 Py_TYPE(self)->tp_free((PyObject *) self);
9079 }
9180
@@ -98,12 +87,12 @@ Py_filterbank_do(Py_filterbank * self, PyObject * args) · 6 unmodified lines
9887 return NULL;
9988 }
10089
101− if (!PyAubio_ArrayToCCvec(input, self->vec)) {
90+ if (!PyAubio_ArrayToCCvec(input, &(self->vec) )) {
10291 return NULL;
10392 }
10493
10594 // compute the function
106− aubio_filterbank_do (self->o, self->vec, self->out);
95+ aubio_filterbank_do (self->o, &(self->vec), self->out);
10796 return (PyObject *)PyAubio_CFvecToArray(self->out);
10897 }
10998
@@ -130,12 +119,12 @@ Py_filterbank_set_triangle_bands (Py_filterbank * self, PyObject *args) · 20 unmodified lines
130119 return NULL;
131120 }
132121
133− if (!PyAubio_ArrayToCFvec(input, self->freqs)) {
122+ if (!PyAubio_ArrayToCFvec(input, &(self->freqs) )) {
134123 return NULL;
135124 }
136125
137126 err = aubio_filterbank_set_triangle_bands (self->o,
138− self->freqs, samplerate);
127+ &(self->freqs), samplerate);
139128 if (err > 0) {
140129 PyErr_SetString (PyExc_ValueError,
141130 "error when setting filter to A-weighting");
@@ -173,11 +162,11 @@ Py_filterbank_set_coeffs (Py_filterbank * self, PyObject *args) · 31 unmodified lines
173162 return NULL;
174163 }
175164
176− if (!PyAubio_ArrayToCFmat(input, self->coeffs)) {
165+ if (!PyAubio_ArrayToCFmat(input, &(self->coeffs))) {
177166 return NULL;
178167 }
179168
180− err = aubio_filterbank_set_coeffs (self->o, self->coeffs);
169+ err = aubio_filterbank_set_coeffs (self->o, &(self->coeffs));
181170
182171 if (err > 0) {
183172 PyErr_SetString (PyExc_ValueError,
python/ext/py-musicutils.c+12−24
@@ -25,7 +25,7 @@ PyObject * · 24 unmodified lines
2525 Py_aubio_level_lin(PyObject *self, PyObject *args)
2626 {
2727 PyObject *input;
28− fvec_t *vec;
28+ fvec_t vec;
2929 PyObject *level_lin;
3030
3131 if (!PyArg_ParseTuple (args, "O:level_lin", &input)) {
@@ -37,14 +37,11 @@ Py_aubio_level_lin(PyObject *self, PyObject *args) · 5 unmodified lines
3737 return NULL;
3838 }
3939
40− vec = (fvec_t *)malloc(sizeof(fvec_t));
41− if (!PyAubio_ArrayToCFvec(input, vec)) {
42− free(vec);
40+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
4341 return NULL;
4442 }
4543
46− level_lin = Py_BuildValue("f", aubio_level_lin(vec));
47− free(vec);
44+ level_lin = Py_BuildValue("f", aubio_level_lin(&vec));
4845 if (level_lin == NULL) {
4946 PyErr_SetString (PyExc_ValueError, "failed computing level_lin");
5047 return NULL;
@@ -57,7 +54,7 @@ PyObject * · 6 unmodified lines
5754 Py_aubio_db_spl(PyObject *self, PyObject *args)
5855 {
5956 PyObject *input;
60− fvec_t *vec;
57+ fvec_t vec;
6158 PyObject *db_spl;
6259
6360 if (!PyArg_ParseTuple (args, "O:db_spl", &input)) {
@@ -69,14 +66,11 @@ Py_aubio_db_spl(PyObject *self, PyObject *args) · 5 unmodified lines
6966 return NULL;
7067 }
7168
72− vec = (fvec_t *)malloc(sizeof(fvec_t));
73− if (!PyAubio_ArrayToCFvec(input, vec)) {
74− free(vec);
69+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
7570 return NULL;
7671 }
7772
78− db_spl = Py_BuildValue("f", aubio_db_spl(vec));
79− free(vec);
73+ db_spl = Py_BuildValue("f", aubio_db_spl(&vec));
8074 if (db_spl == NULL) {
8175 PyErr_SetString (PyExc_ValueError, "failed computing db_spl");
8276 return NULL;
@@ -89,7 +83,7 @@ PyObject * · 6 unmodified lines
8983 Py_aubio_silence_detection(PyObject *self, PyObject *args)
9084 {
9185 PyObject *input;
92− fvec_t *vec;
86+ fvec_t vec;
9387 PyObject *silence_detection;
9488 smpl_t threshold;
9589
@@ -102,14 +96,11 @@ Py_aubio_silence_detection(PyObject *self, PyObject *args) · 6 unmodified lines
10296 return NULL;
10397 }
10498
105− vec = (fvec_t *)malloc(sizeof(fvec_t));
106− if (!PyAubio_ArrayToCFvec(input, vec)) {
107− free(vec);
99+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
108100 return NULL;
109101 }
110102
111− silence_detection = Py_BuildValue("I", aubio_silence_detection(vec, threshold));
112− free(vec);
103+ silence_detection = Py_BuildValue("I", aubio_silence_detection(&vec, threshold));
113104 if (silence_detection == NULL) {
114105 PyErr_SetString (PyExc_ValueError, "failed computing silence_detection");
115106 return NULL;
@@ -122,7 +113,7 @@ PyObject * · 6 unmodified lines
122113 Py_aubio_level_detection(PyObject *self, PyObject *args)
123114 {
124115 PyObject *input;
125− fvec_t *vec;
116+ fvec_t vec;
126117 PyObject *level_detection;
127118 smpl_t threshold;
128119
@@ -135,14 +126,11 @@ Py_aubio_level_detection(PyObject *self, PyObject *args) · 6 unmodified lines
135126 return NULL;
136127 }
137128
138− vec = (fvec_t *)malloc(sizeof(fvec_t));
139− if (!PyAubio_ArrayToCFvec(input, vec)) {
140− free(vec);
129+ if (!PyAubio_ArrayToCFvec(input, &vec)) {
141130 return NULL;
142131 }
143132
144− level_detection = Py_BuildValue("f", aubio_level_detection(vec, threshold));
145− free(vec);
133+ level_detection = Py_BuildValue("f", aubio_level_detection(&vec, threshold));
146134 if (level_detection == NULL) {
147135 PyErr_SetString (PyExc_ValueError, "failed computing level_detection");
148136 return NULL;
python/ext/py-phasevoc.c+6−13
@@ -1,17 +1,15 @@
11 #include "aubio-types.h"
22
3−static char Py_pvoc_doc[] = "pvoc object";
4−
53 typedef struct
64 {
75 PyObject_HEAD
86 aubio_pvoc_t * o;
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;
1715
@@ -71,9 +69,6 @@ Py_pvoc_init (Py_pvoc * self, PyObject * args, PyObject * kwds) · 53 unmodified lines
7169 return -1;
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);
7974 self->routput = new_fvec(self->hop_s);
@@ -88,8 +83,6 @@ Py_pvoc_del (Py_pvoc *self, PyObject *unused) · 8 unmodified lines
8883 del_aubio_pvoc(self->o);
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 }
9588
@@ -103,12 +96,12 @@ Py_pvoc_do(Py_pvoc * self, PyObject * args) · 7 unmodified lines
10396 return NULL;
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);
114107 PyObject* output = PyAubio_CCvecToPyCvec(self->output, py_out);
@@ -135,12 +128,12 @@ Py_pvoc_rdo(Py_pvoc * self, PyObject * args) · 20 unmodified lines
135128 return NULL;
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 }
146139
python/ext/py-sink.c+7−13
@@ -7,8 +7,8 @@ typedef struct · 6 unmodified lines
77 char_t* uri;
88 uint_t samplerate;
99 uint_t channels;
10− fvec_t *write_data;
11− fmat_t *mwrite_data;
10+ fvec_t write_data;
11+ fmat_t mwrite_data;
1212 } Py_sink;
1313
1414 static char Py_sink_doc[] = ""
@@ -123,10 +123,6 @@ Py_sink_init (Py_sink * self, PyObject * args, PyObject * kwds) · 108 unmodified lines
123123 self->samplerate = aubio_sink_get_samplerate ( self->o );
124124 self->channels = aubio_sink_get_channels ( self->o );
125125
126− self->write_data = (fvec_t *)malloc(sizeof(fvec_t));
127− self->mwrite_data = (fmat_t *)malloc(sizeof(fmat_t));
128− self->mwrite_data->height = self->channels;
129− self->mwrite_data->data = (smpl_t **)malloc(sizeof(smpl_t*) * self->channels);
130126 return 0;
131127 }
132128
@@ -134,9 +130,7 @@ static void · 1 unmodified line
134130 Py_sink_del (Py_sink *self, PyObject *unused)
135131 {
136132 del_aubio_sink(self->o);
137− free(self->write_data);
138− free(self->mwrite_data->data);
139− free(self->mwrite_data);
133+ free(self->mwrite_data.data);
140134 Py_TYPE(self)->tp_free((PyObject *) self);
141135 }
142136
@@ -156,13 +150,13 @@ Py_sink_do(Py_sink * self, PyObject * args) · 13 unmodified lines
156150 }
157151
158152 /* input vectors parsing */
159− if (!PyAubio_ArrayToCFvec(write_data_obj, self->write_data)) {
153+ if (!PyAubio_ArrayToCFvec(write_data_obj, &(self->write_data))) {
160154 return NULL;
161155 }
162156
163157
164158 /* compute _do function */
165− aubio_sink_do (self->o, self->write_data, write);
159+ aubio_sink_do (self->o, &(self->write_data), write);
166160
167161 Py_RETURN_NONE;
168162 }
@@ -184,12 +178,12 @@ Py_sink_do_multi(Py_sink * self, PyObject * args) · 15 unmodified lines
184178
185179
186180 /* input vectors parsing */
187− if (!PyAubio_ArrayToCFmat(write_data_obj, self->mwrite_data)) {
181+ if (!PyAubio_ArrayToCFmat(write_data_obj, &(self->mwrite_data))) {
188182 return NULL;
189183 }
190184
191185 /* compute _do function */
192− aubio_sink_do_multi (self->o, self->mwrite_data, write);
186+ aubio_sink_do_multi (self->o, &(self->mwrite_data), write);
193187 Py_RETURN_NONE;
194188 }
195189
python/lib/gen_code.py+8−8
@@ -202,7 +202,9 @@ typedef struct{{ · 201 unmodified lines
202202 {output_results};
203203 }} Py_{shortname};
204204 """
205− return out.format(do_inputs_list = "; ".join(get_input_params(self.do_proto)), **self.__dict__)
205+ # fmat_t* / fvec_t* / cvec_t* inputs -> full fvec_t /.. struct in Py_{shortname}
206+ do_inputs_list = "; ".join(get_input_params(self.do_proto)).replace('fvec_t *','fvec_t').replace('fmat_t *', 'fmat_t').replace('cvec_t *', 'cvec_t')
207+ return out.format(do_inputs_list = do_inputs_list, **self.__dict__)
206208
207209 def gen_doc(self):
208210 out = """
@@ -310,9 +312,6 @@ Py_{shortname}_init (Py_{shortname} * self, PyObject * args, PyObject * kwds) · 101 unmodified lines
310312 out += """
311313 // TODO get internal params after actual object creation?
312314 """
313− for input_param in self.do_inputs:
314− out += """
315− self->{0} = ({1})malloc(sizeof({2}));""".format(input_param['name'], input_param['type'], input_param['type'][:-1])
316315 out += """
317316 // create outputs{output_create}
318317 """.format(output_create = output_create)
@@ -342,8 +341,9 @@ static void · 23 unmodified lines
342341 Py_{shortname}_del (Py_{shortname} * self, PyObject * unused)
343342 {{""".format(**self.__dict__)
344343 for input_param in self.do_inputs:
345− out += """
346− free(self->{0[name]});""".format(input_param)
344+ if input_param['type'] == 'fmat_t *':
345+ out += """
346+ free(self->{0[name]}.data);""".format(input_param)
347347 for o in self.outputs:
348348 name = o['name']
349349 del_out = delfromtype_fn[o['type']]
@@ -379,11 +379,11 @@ Py_{shortname}_do (Py_{shortname} * self, PyObject * args) · 29 unmodified lines
379379 }}""".format(refs = refs, pyparamtypes = pyparamtypes, **self.__dict__)
380380 for p in input_params:
381381 out += """
382− if (!{pytoaubio}(py_{0[name]}, self->{0[name]})) {{
382+ if (!{pytoaubio}(py_{0[name]}, &(self->{0[name]}))) {{
383383 return NULL;
384384 }}""".format(input_param, pytoaubio = pytoaubio_fn[input_param['type']])
385385 do_fn = get_name(self.do_proto)
386− inputs = ", ".join(['self->'+p['name'] for p in input_params])
386+ inputs = ", ".join(['&(self->'+p['name']+')' for p in input_params])
387387 outputs = ", ".join(["self->%s" % p['name'] for p in self.do_outputs])
388388 out += """
389389

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