scc

simple c99 compiler
git clone git://git.simple-cc.org/scc
Log | Files | Refs | README | LICENSE

commit f1689426d892911f774884c79ecdc2e639522448
parent 70920c23871f743fcdd012868694af575fc9045b
Author: Roberto E. Vargas Caballero <k0ga@shike2.com>
Date:   Thu, 19 Jan 2017 12:24:55 +0100

[cc1] Use newitem() in incdir()

This why newitem() was created.

Diffstat:
Mcc1/cpp.c | 12+++++-------
1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/cc1/cpp.c b/cc1/cpp.c @@ -16,8 +16,8 @@ static unsigned arglen; 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 @@ incdir(char *dir) { 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 @@ include(void) 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; }