shithub: scc

Download patch

ref: 07a7f1fec37694de82495c433073c606ea3b483c
parent: 797f25e748cafa8718533af9d9a22642f2992de9
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Thu Jan 19 07:24:55 EST 2017

[cc1] Use newitem() in incdir()

This why newitem() was created.

--- a/cc1/cpp.c
+++ b/cc1/cpp.c
@@ -16,8 +16,8 @@
 static unsigned ncmdlines;
 static Symbol *symline, *symfile;
 static unsigned char ifstatus[NR_COND];
-static int ninclude, cppoff;
-static char **dirinclude;
+static int cppoff;
+static struct items dirinclude;
 
 unsigned cppctx;
 int disexpand;
@@ -417,9 +417,7 @@
 {
 	if (!dir || *dir == '\0')
 		die("incorrect -I flag");
-	++ninclude;
-	dirinclude = xrealloc(dirinclude, sizeof(*dirinclude) * ninclude);
-	dirinclude[ninclude-1] = dir;
+	newitem(&dirinclude, dir);
 }
 
 static int
@@ -499,8 +497,8 @@
 		goto bad_include;
 	}
 
-	n = ninclude;
-	for (bp = dirinclude; n--; ++bp) {
+	n = dirinclude.n;
+	for (bp = dirinclude.s; n--; ++bp) {
 		if (includefile(*bp, file, filelen))
 			goto its_done;
 	}