-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
some more comments, to fill in the gaps:
On 2011-04-27 13:51, IOhannes m zmoelnig wrote:
a quick glance at lpcanalysis_tilde_new() reveils, that you are allocating data on the stack (which will be freed as soon as you leave lpcanalysis_tilde_new()!), store their addresses and re-use them later (when the memory is already freed).
which is not a good idea. instead, you have to allocate on the heap, and manually free once you don't need the data anymore.
you cannot do:
<ko> void*lpca_new() { //... t_sample winlis[2088]; x->win=winlis; //... } </ko>
instead you have to do:
<ok> void lpca_free(x) { freebytes(x->win);
which really should read: freebytes(x->win, 2088*sizeof(t_sample));
//... } void*lpca_new() { //... x->win=getbytes(2088*sizeof(t_sample)); //... }
</ok>
and of course it would be nice, if 2088 was not hardcoded, but insteadbe settable; e.g. <nice> void lpca_free(x) { freebytes(x->win, x->winsize*sizeof(t_sample)); //... } void*lpca_new() { //... x->winsize=2088; x->win=getbytes(x->winsize*sizeof(t_sample)); //... } </nice>
fgmasdr IOhannes
_______________________________________________ Pd-dev mailing list Pd-dev@iem.at http://lists.puredata.info/listinfo/pd-dev