Hi devs,
I'm trying to rewrite some of my externals to be a bit more effe\icient, clear up after themselves and generally work more smoothly. I started with maskxor, because I really need this to work for the ICMC, and it's not working properly in certain situations.
So I borrowed some code from zexy/src/drip.c and rewrote it. It compiled OK, but crashes PD. Can anyone tell me what is wrong with my code, and how to fix it?
Best, Ed
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
--------------------------------- Yahoo! Answers - Get better answers from someone who knows. Tryit now.
Ed Kelly wrote:
Hi devs,
I'm trying to rewrite some of my externals to be a bit more effe\icient, clear up after themselves and generally work more smoothly. I started with maskxor, because I really need this to work for the ICMC, and it's not working properly in certain situations.
So I borrowed some code from zexy/src/drip.c and rewrote it. It compiled OK, but crashes PD. Can anyone tell me what is wrong with my code, and how to fix it?
I guess because you don't initialize the pointers the first time. Your maskxor_new has:
SETFLOAT(&x->masking.maskr[0], 0); SETFLOAT(&x->masking.maskl[0], 0); SETFLOAT(&x->masking.maskxor[0], 0); ...but x->masking.maskr etc. don't yet point to anything, they were declared as: t_atom *maskxor, *maskl, *maskr; ...but not given any value. If it doesn't crash right there it will do so when you try to free the pointers: if (x->masking.maskl) { freebytes(x->masking.maskl, x->lengthl * sizeof(t_atom)); x->masking.maskl = 0; x->lengthl = 0; } Martin
Best, Ed
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
Yahoo! Answers - Get better answers from someone who knows. Try it now http://uk.answers.yahoo.com/;_ylc=X3oDMTEydmViNG02BF9TAzIxMTQ3MTcxOTAEc2VjA21haWwEc2xrA3RhZ2xpbmU.
PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
So... if I initialize the pointers the first time they are used, maybe that will help. It makes sense that the _new routine would be causing the problem, since it crashes when I load the object (PD disappears...) I'll try it!
Ta, Ed
Martin Peach martin.peach@sympatico.ca wrote: Ed Kelly wrote:
Hi devs,
I'm trying to rewrite some of my externals to be a bit more effe\icient, clear up after themselves and generally work more smoothly. I started with maskxor, because I really need this to work for the ICMC, and it's not working properly in certain situations.
So I borrowed some code from zexy/src/drip.c and rewrote it. It compiled OK, but crashes PD. Can anyone tell me what is wrong with my code, and how to fix it?
I guess because you don't initialize the pointers the first time. Your maskxor_new has:
SETFLOAT(&x->masking.maskr[0], 0); SETFLOAT(&x->masking.maskl[0], 0); SETFLOAT(&x->masking.maskxor[0], 0); ...but x->masking.maskr etc. don't yet point to anything, they were declared as: t_atom *maskxor, *maskl, *maskr; ...but not given any value. If it doesn't crash right there it will do so when you try to free the pointers: if (x->masking.maskl) { freebytes(x->masking.maskl, x->lengthl * sizeof(t_atom)); x->masking.maskl = 0; x->lengthl = 0; } Martin
Best, Ed
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
Yahoo! Answers - Get better answers from someone who knows. Try it now .
PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
--------------------------------- Yahoo! Answers - Get better answers from someone who knows. Tryit now.
Splendid! It doesn't crash any more. It doesn't work either, but at least I'm in more familiar debugging territory! Thanks.
I used a x->firstl, x->firstr and x->firstx variables that were tested and set, so that the first time each list is initialized, the first thing that happens is e.g. x->masking.maskl = getbytes(n * sizeof(t_atom)); and then the freebytes is used the second, third, fourth etc times.
Cheers, Ed
Martin Peach martin.peach@sympatico.ca wrote: Ed Kelly wrote:
Hi devs,
I'm trying to rewrite some of my externals to be a bit more effe\icient, clear up after themselves and generally work more smoothly. I started with maskxor, because I really need this to work for the ICMC, and it's not working properly in certain situations.
So I borrowed some code from zexy/src/drip.c and rewrote it. It compiled OK, but crashes PD. Can anyone tell me what is wrong with my code, and how to fix it?
I guess because you don't initialize the pointers the first time. Your maskxor_new has:
SETFLOAT(&x->masking.maskr[0], 0); SETFLOAT(&x->masking.maskl[0], 0); SETFLOAT(&x->masking.maskxor[0], 0); ...but x->masking.maskr etc. don't yet point to anything, they were declared as: t_atom *maskxor, *maskl, *maskr; ...but not given any value. If it doesn't crash right there it will do so when you try to free the pointers: if (x->masking.maskl) { freebytes(x->masking.maskl, x->lengthl * sizeof(t_atom)); x->masking.maskl = 0; x->lengthl = 0; } Martin
Best, Ed
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
Yahoo! Answers - Get better answers from someone who knows. Try it now .
PD-dev mailing list PD-dev@iem.at http://lists.puredata.info/listinfo/pd-dev
Lone Shark "Aviation" out now on http://www.pyramidtransmissions.com http://www.myspace.com/sharktracks
--------------------------------- Yahoo! Answers - Get better answers from someone who knows. Tryit now.