Здравствуйте, у меня есть такой код, для кривой безье
struct pt{
	GLfloat x;
	GLfloat y;
};
typedef struct pt Pt;
struct rc{
	Pt lt;
	Pt rt;
	Pt rb;
	Pt lb;
};
typedef struct rc Rc;
Pt add(Pt a,Pt b){
	Pt r;
	r.x = a.x + b.x;
	r.y = a.y + b.y;
	return r;
}
Pt sub(Pt a,Pt b){
	Pt r;
	r.x = a.x - b.x;
	r.y = a.y - b.y;
	return r;
}
Pt mul(Pt a,GLfloat k){
	Pt r;
	r.x = a.x * k;
	r.y = a.y * k;
	return r;
}
void bezier(Pt p1, Pt p2, Pt p3, GLfloat step, Pt* res){
	Pt v1,v2;
	v1 = sub(p2,p1);
	v2 = sub(p3,p2);
	GLfloat c = step;
	res[0] = p1;
	int i;
	for(i=1; c < 1; ++i, c += step){
		Pt p = add(p1,mul(v1,c));
		Pt v = sub(add(p2,mul(v2,c)),p);
		res[i] = add(p,mul(v,c));
	}
	res[i] = p3;
}int main(){
	Pt arr[11];
	Pt a,b,c;
	a.x = -1;
	a.y = 0;
	b.x = 0;
	b.y = 1;
	c.x = 1;
	c.y = 0;
	bezier(a,b,c,0.1,arr);
//	bezier((double)fax,(double)fay,(double)fbx,(double)fby,(double)fcx,(double)fcy,0.1,arr);
	for(int i=0; i<11; ++i)
		printf("(%f, %f),\n",arr[i].x,arr[i].y);
	return 0;
}
int main(){
	Pt *arr = malloc(sizeof(Pt) * 11);
	Pt a,b,c;
	a.x = -1;
	a.y = 0;
	b.x = 0;
	b.y = 1;
	c.x = 1;
	c.y = 0;
	bezier(a,b,c,0.1,arr);
//	bezier((double)fax,(double)fay,(double)fbx,(double)fby,(double)fcx,(double)fcy,0.1,arr);
	for(int i=0; i<11; ++i)
		printf("(%f, %f),\n",arr[i].x,arr[i].y);
	free(arr);
	return 0;
}
*** glibc detected *** ./textTest: double free or corruption (out): 0x0000000000e31010 ***
textTest: malloc.c:2451: sYSMALLOc: Assertion `(old_top == (((mbinptr) (((char *) &((av)->bins[((1) - 1) * 2])) - __builtin_offsetof (struct malloc_chunk, fd)))) && old_size == 0) || ((unsigned long) (old_size) >= (unsigned long)((((__builtin_offsetof (struct malloc_chunk, fd_nextsize))+((2 * (sizeof(size_t))) - 1)) & ~((2 * (sizeof(size_t))) - 1))) && ((old_top)->size & 0x1) && ((unsigned long)old_end & pagemask) == 0)' failed.
Aborted (core dumped)
make: *** [c] Ошибка 134




