[PD-dev] help-array crashing outlet_anything

nosehair911 at bellsouth.net nosehair911 at bellsouth.net
Wed Jul 25 17:10:20 CEST 2007


I have been trying to figure this out for 4 days now without any solutions.  Maybe someone here can 
help me.  I have a class that stores a few integers and returns them. something like this:

class Intstore {
public:
	Intstore();
         int m_xmax;
         int m_ymax;
	int xmax() {return m_xmax};
         int ymax() {return m_ymax};
}

Intstore *storepointer;

I also have a function to store arrays of the class like this:

void myexternal :: addToArray(Intstore *pointer, int arraynumber) {
	storepointer[arraynumber] = *pointer;
	}

So when I store arrays I do something like:

Intstore *storepointer = new Intstore();

for (i=0; i<anumber; i++) {
storepointer->m_xmax = (whatever int);
storepointer->m_ymax = (whatever int);
addToArray(storepointer, i)
}

So to send it out an outlet I do this:

t_atom*ap = new t_atom[2+anumber*2];
for(bn=0; bn<anumber; bn++){
		SETFLOAT(ap+bn*2, x->storepointer[bn].xmax());
		SETFLOAT(ap+bn*2+1, x->storepointer[bn].ymax());
}
outlet_anything(x->outlet1, 2+anumber*2, ap);

This works fine for regular operations but when I get a heavy cpu load on some other operation I get a 
Pd crash like this:

Thread 0 Crashed:
0   pd                             	0x00061c40 outlet_anything + 80 

Now if I remove the "addToArray(storepointer, forloopnumber)" function even on heavy cpu loads the 
external does not crash and works perfect but odviously my data is not passed out of the outlet.
Is there a mistake I am making here somewhere? Is there a more simple way to do this? I dont 
undestand what is happening here or why its crashing?

BTW its a blobtracking external.  It is working perfect tracking quicktime movies but the camera 
tracking only works if I exclude the addToArray function. This really has me scratching my head!

Sorry for the long post,
Alain





More information about the Pd-dev mailing list