summary refs log tree commit diff
path: root/util.c
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-13 12:34:55 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2016-04-13 12:39:57 -0400
commit9441c55fc67c2824353a6f2ba99b9a232a26f782 (patch)
treebbb047e7c641f8fda64db0de636538ef72bba031 /util.c
parentdc2fad446277cb464bcc1182a7d757785f7d51d7 (diff)
downloadroux-9441c55fc67c2824353a6f2ba99b9a232a26f782.tar.gz
oops, memcpy -> memmove
Diffstat (limited to 'util.c')
-rw-r--r--util.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/util.c b/util.c
index 5eda5e5..96efdfd 100644
--- a/util.c
+++ b/util.c
@@ -100,27 +100,28 @@ blknew()
 void
 blkdel(Blk *b)
 {
-	Blk *s, **ps;
+	Blk *s, **ps, *succ[3];
 	Phi *p;
 	uint a;
 
-	if (b->s1 == b->s2) /* do not delete twice */
-		b->s2 = 0;
-	for (ps=(Blk*[]){b->s1, b->s2, 0}; (s=*ps); ps++) {
+	succ[0] = b->s1;
+	succ[1] = b->s2 == b->s1 ? 0 : b->s2;
+	succ[2] = 0;
+	for (ps=succ; (s=*ps); ps++) {
 		for (p=s->phi; p; p=p->link) {
 			for (a=0; p->blk[a]!=b; a++)
 				assert(a+1<p->narg);
 			p->narg--;
-			memcpy(&p->blk[a], &p->blk[a+1],
+			memmove(&p->blk[a], &p->blk[a+1],
 				sizeof p->blk[0] * (p->narg-a));
-			memcpy(&p->arg[a], &p->arg[a+1],
+			memmove(&p->arg[a], &p->arg[a+1],
 				sizeof p->arg[0] * (p->narg-a));
 		}
 		if (s->npred != 0) {
 			for (a=0; s->pred[a]!=b; a++)
 				assert(a+1<s->npred);
 			s->npred--;
-			memcpy(&s->pred[a], &s->pred[a+1],
+			memmove(&s->pred[a], &s->pred[a+1],
 				sizeof s->pred[0] * (s->npred-a));
 		}
 	}