shithub: boids

Download patch

ref: c068285f1ce7870e64c14341a3e9cfa79f6de6aa
parent: 4913576c796b473892aa2d3e5d87f191fd0e915a
author: rodri <rgl@antares-labs.eu>
date: Mon Jun 15 02:41:56 EDT 2020

cleanup and adjustments.

--- a/main.c
+++ b/main.c
@@ -58,8 +58,9 @@
 	f = malloc(sizeof(Flock));
 	if(f == nil)
 		sysfatal("malloc: %r");
-	setmalloctag(f, getcallerpc(&nbirds));
-	f->birds = nil;
+	f->birds = malloc(nbirds*sizeof(Bird));
+	if(f->birds == nil)
+		sysfatal("malloc: %r");
 	f->nbirds = nbirds;
 	f->jail = jail;
 	f->separate = flockseparate;
@@ -67,10 +68,6 @@
 	f->cohesion = flockcohesion;
 	f->step = flockstep;
 
-	f->birds = malloc(nbirds*sizeof(Bird));
-	if(f->birds == nil)
-		sysfatal("malloc: %r");
-	setmalloctag(f->birds, getcallerpc(&nbirds));
 	for(b = f->birds; b < f->birds + f->nbirds; b++){
 		b->p = Pt2(frand()*jail.max.x + jail.min.x,frand()*jail.max.y + jail.min.y,1);
 		b->v = Vec2(cos(frand()*2*PI),sin(frand()*2*PI));
@@ -158,7 +155,7 @@
 flockstep(Flock *f)
 {
 	static double Δt = 1;
-	static Point2 a = {2,2}; /* deceleration */
+	static Point2 a = {1,1}; /* deceleration */
 	Bird *b;
 
 	f->separate(f);