Hi,
I’m having a real big problem with crashes. I’m not quite sure why I get the crashes either, and just wondering if the following code looks ok.
The actual code doesn’t do anything interesting, I have just wrote it like this to simplify it so people don’t get confused as easy.
Vector f(Vector p0, Vector p1)
{
return p0*p1;
}
Vector RecursiveF(Vector *points, LONG cnt)
{
cnt--;
if(cnt==1)
{
Vector ret = f(points[0],points[1]);
delete [] points;
return ret;
}
Vector *sub = new Vector(cnt+1);
for(LONG j=0; j < cnt;j++)
sub[j]=Vector(0);
for(LONG i=0; i < cnt;i++)
{
sub[i]=f(points[i],points[i+1]);
}
Vector ret = RecursiveF(sub,cnt);
delete [] sub;
return ret;
}
What this does is loops through all the points passed to it. It creates a new point from two of the points and stores that new point into an array. It does this with all the points. It then calls itself and repeats until it finally ends with just one point.
The Vector variable type is just a datatype that holds an XYZ coordinate.
The RecursiveF gets called every frame, and it seems (though I’m not certain) it works fine the first time it runs, then after it will crash my software (the code runs as a plugin) with Access Violation
I think its because theres a rogue pointer or something hanging about. Can anyone see a problem with the above code?
Thanks