Re: [PD-dev] Trouble with memory+pointers

2007-06-25 Thread Ed Kelly
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 <[EMAIL PROTECTED]> 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.___
PD-dev mailing list
PD-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Trouble with memory+pointers

2007-06-25 Thread Ed Kelly
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 <[EMAIL PROTECTED]> 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.___
PD-dev mailing list
PD-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


Re: [PD-dev] Trouble with memory+pointers

2007-06-25 Thread Martin Peach
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
>   


___
PD-dev mailing list
PD-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev


[PD-dev] Trouble with memory+pointers

2007-06-25 Thread Ed Kelly
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.

maskxor.tgz
Description: 2539302602-maskxor.tgz
___
PD-dev mailing list
PD-dev@iem.at
http://lists.puredata.info/listinfo/pd-dev