Waitrud Weber’s blog

things and reminders for memories

3d: parabola and memorization: we lost a pointer.

(20201114: )
if t=0, the point is in the midle between p1 and p2, so, we add ( - the middle point )

And, middle_001 is a new pointer, and we do not control the pointer after the function add returns so that we could lose a pointer.

middle_001 = calc->add(middle_001, p3);

The below is not a so good solutions.

solution1:
vPoint* middle_002 = calc->add(middle_001, p3);

if ( middle_002.equals(middle_001) ) {
	free_point ( middle_002 );
}

 

There are solutions.

 

solution1:
calc->add(middle_001, p3, middle_001);
void vCalculation::add(vPoint* a, vPoint *b, vPoint *c);
solution2: create the void add:
void vCalculation::add(vPoint* a, vPoint *b);

 

Anyway, we could display parabora.

f:id:Waitrud_Weber:20201114194826j:plain